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