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.category.Category;
23 import org.mxchange.pizzaapplication.product.Product;
27 * @author Roland Haeder
29 public interface PizzaApplication extends Application {
31 * HTTP parameter "amount"
33 public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
36 * HTTP parameter "choose"
38 public static final String HTTP_PARAM_CHOOSE = "choose"; //NOI18N
41 * Session key "ordered"
43 public static final String SESSION_ORDERED = "ordered"; //NOI18N
46 * Mask for all parameters
48 public static final String HTTP_PARAM_MASK = "%s[%s]"; //NOI18N
51 * Some "getter" for amount from session
53 * @param product Product instance
54 * @param session Session instance
55 * @return Amount as string
57 public String getAmountFromSession (final Product product, final HttpSession session);
60 * Some "getter" for choose from session
62 * @param product Product instance
63 * @param session Session instance
64 * @return Choose as string
66 public String getChooseFromSession (final Product product, final HttpSession session);
69 * Handler for amount from session
71 * @param product Product instance
72 * @param request Request instance
73 * @param session Session instance
74 * @return Amount as string
76 public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
79 * Some "getter" for printable choosen (checkbox) from request or session
81 * @param product Product instance
82 * @param request Request instance
83 * @param session Session instance
84 * @return Amount as string
86 public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
89 * Some "getter" for total price of position from request or session.
90 * Single price and amount is multiplyed.
92 * @param product Product instance
93 * @param request Request instance
94 * @param session Session instance
95 * @return Amount as string
97 public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
100 * Checks whether the given product is choosen, request overules session.
102 * @param product Product instance
103 * @param request Request instance
104 * @param session Session instance
105 * @return Whether the product is choosen
107 public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
110 * Calculates total price of all choosen products
112 * @param request Request instance
113 * @param session Session instance
114 * @return Total price of all choosen products
116 public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session);
119 * Calculates total amount of all choosen products
121 * @param request Request instance
122 * @param session Session instance
123 * @return Total amount of all choosen products
125 public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session);
128 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
130 * @param product Product instance
131 * @param request Request instance
132 * @param session Session instance
133 * @return Whether the product is choosen
135 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
138 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
140 * @param request Request instance
141 * @param session Session instance
142 * @return Whether the product is choosen
144 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session);
147 * Marks given product as ordered in session
149 * @param product Product to mark as ordered
150 * @param session Session instance
152 public void markProductAsOrdered(final Product product, final HttpSession session);
155 * Marks given product as choosen in session
157 * @param product Product to mark as ordered
158 * @param session Session instance
160 public void markProductAsChoosen(final Product product, final HttpSession session);
163 * Unmarks given product as ordered in session
165 * @param product Product to unmark as ordered
166 * @param session Session instance
168 public void unmarkProductAsOrdered(final Product product, final HttpSession session);
171 * Unmarks given product as choosen in session
173 * @param product Product to unmark as choosen
174 * @param session Session instance
176 public void unmarkProductAsChoosen(final Product product, final HttpSession session);
179 * Some getter for printable value from session or an empty string for null.
181 * @param session Session instance
182 * @param key Key to get
183 * @return Value from key, empty string for null
185 public Object getPrintableValeFromSession (final HttpSession session, final String key);
188 * Somewhat setter in session
190 * @param session Session instance
191 * @param key Session key to set
192 * @param value Value to set
194 public void setValueInSession (final HttpSession session, final String key, final Object value);
197 * Some "getter" for a an array of all products
199 * @return All products
201 public Iterable<Product> getProducts ();
204 * Some "getter" for a an array of all categories
206 * @return All categories
208 public Iterable<Category> getCategories ();
211 * Checks if given Product instance is available and returns a printable
212 * (human-readable) string.
214 * @param product Product instance to check
215 * @return Human-readable version of product availability
217 public String getPrintableProduktAvailability (final Product product);