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 java.util.Iterator;
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;
28 * @author Roland Haeder
30 public interface PizzaApplication extends Application {
32 * HTTP parameter "amount"
34 public static final String HTTP_PARAM_AMOUNT = "amount";
37 * HTTP parameter "choose"
39 public static final String HTTP_PARAM_CHOOSE = "choose";
42 * Session key "ordered"
44 public static final String SESSION_ORDERED = "ordered";
47 * Mask for all parameters
49 public static final String HTTP_PARAM_MASK = "%s[%s]";
52 * Getter for product iterator
54 * @return Iterator for all products
56 public Iterator<Map.Entry<String, Product>> getProductsIterator ();
59 * Some "getter" for amount from session
61 * @param product Product instance
62 * @param session Session instance
63 * @return Amount as string
65 public String getAmountFromSession (final Product product, final HttpSession session);
68 * Some "getter" for choose from session
70 * @param product Product instance
71 * @param session Session instance
72 * @return Choose as string
74 public String getChooseFromSession (final Product product, final HttpSession session);
77 * Handler for amount from session
79 * @param product Product instance
80 * @param request Request instance
81 * @param session Session instance
82 * @return Amount as string
84 public String handleAmountFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
87 * Handler for choosen (checkbox) from request or session
89 * @param product Product instance
90 * @param request Request instance
91 * @param session Session instance
92 * @return Amount as string
94 public String handleChooseFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
97 * Some "getter" for printable choosen (checkbox) from request or session
99 * @param product Product instance
100 * @param request Request instance
101 * @param session Session instance
102 * @return Amount as string
104 public String getPrintableChoosenFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
107 * Some "getter" for total price of position from request or session.
108 * Single price and amount is multiplyed.
110 * @param product Product instance
111 * @param request Request instance
112 * @param session Session instance
113 * @return Amount as string
115 public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session);
118 * Checks whether the given product is choosen, request overules session.
120 * @param product Product instance
121 * @param request Request instance
122 * @param session Session instance
123 * @return Whether the product is choosen
125 public boolean isProductChoosen (final Product product, final HttpServletRequest request, final HttpSession session);
128 * Calculates total price of all choosen products
130 * @param request Request instance
131 * @param session Session instance
132 * @return Total price of all choosen products
134 public float calculateTotalPrice (final HttpServletRequest request, final HttpSession session);
137 * Calculates total amount of all choosen products
139 * @param request Request instance
140 * @param session Session instance
141 * @return Total amount of all choosen products
143 public int calculateTotalAmount (final HttpServletRequest request, final HttpSession session);
146 * Some "getter" for HTML code 'checked="checked"' if the product is choosen
148 * @param product Product instance
149 * @param request Request instance
150 * @param session Session instance
151 * @return Whether the product is choosen
153 public String getCheckedHtmlFromProduct (final Product product, final HttpServletRequest request, final HttpSession session);
156 * Some "getter" for HTML code 'disabled="disabled"' for e.g. submit buttons
158 * @param request Request instance
159 * @param session Session instance
160 * @return Whether the product is choosen
162 public String getDisabledHtmlFromSession (final HttpServletRequest request, final HttpSession session);
165 * Marks given product as ordered in session
167 * @param product Product to mark as ordered
168 * @param session Session instance
170 public void markProductAsOrdered(final Product product, final HttpSession session);
173 * Unmarks given product as ordered in session
175 * @param product Product to unmark as ordered
176 * @param session Session instance
178 public void unmarkProductAsOrdered(final Product product, final HttpSession session);