]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with project:
authorRoland Haeder <roland@mxchange.org>
Wed, 26 Aug 2015 12:39:32 +0000 (14:39 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 26 Aug 2015 12:39:32 +0000 (14:39 +0200)
- Had to renamed id -> itemId and categoryId accordingly to allow databased- baskets
- Implemented almost all methods in basket database frontend class
- Added constants class for above frontend
- Updated jcore
Signed-off-by:Roland Häder <roland@mxchange.org>

29 files changed:
lib/jcore.jar
src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java
src/java/org/mxchange/pizzaapplication/basket/Basket.java
src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java
src/java/org/mxchange/pizzaapplication/category/BaseCategory.java
src/java/org/mxchange/pizzaapplication/category/Category.java
src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java
src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java
src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java
src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java
src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java
src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java
src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java
src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java
src/java/org/mxchange/pizzaapplication/item/AddableBasketItem.java
src/java/org/mxchange/pizzaapplication/item/BaseItem.java
src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java
src/java/org/mxchange/pizzaapplication/product/BaseProduct.java
src/java/org/mxchange/pizzaapplication/product/Product.java
src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java
web/admin/category.jsp
web/admin/product.jsp
web/index.jsp
web/index.xhtml
web/static/admin/admin_category_selection_box.jsp
web/static/admin/admin_parent_category_selection_box.jsp

index b40acb8717dea690b57943fc2d49e304bed8278f..03f8053610357bd974371cda9b66d6e5dddfcd39 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index 09993d40a28168e02561b2c89f63e799627d9fa8..378291058af45c260f667f969fe408c86a6daf19 100644 (file)
@@ -43,9 +43,9 @@ public interface PizzaApplication extends Application {
        public static final String HTTP_PARAM_AMOUNT = "amount"; //NOI18N
 
        /**
-        * HTTP parameter "id"
+        * HTTP parameter "item_id"
         */
-       public static final String HTTP_PARAM_ITEM_ID = "id"; //NOI18N
+       public static final String HTTP_PARAM_ITEM_ID = "item_id"; //NOI18N
 
        /**
         * HTTP parameter "type"
index f1a8fd1fabd0ecba40fd6c363e18727c3f26c98f..459d6c7d98fcd7cde77491c690d4181f58b1f98b 100644 (file)
@@ -184,7 +184,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                        // Is this choosen?
                        if (this.isProductChoosen(product, request, session)) {
                                // Then add ordered amount
-                               this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getId())); //NOI18N
+                               this.getLogger().debug(MessageFormat.format("Counting {0} ...", product.getItemId())); //NOI18N
 
                                // Getting amount
                                String amount = this.getAmountFromSession(product, session);
@@ -193,7 +193,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                                this.getLogger().debug(MessageFormat.format("amount={0}", amount)); //NOI18N
                                totalAmount += Integer.valueOf(amount);
                        }
-                       this.getLogger().debug(MessageFormat.format("product={0},totalAmount={1}", product.getId(), totalAmount)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},totalAmount={1}", product.getItemId(), totalAmount)); //NOI18N
                }
 
                // Trace message
@@ -238,10 +238,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                        // Is this choosen?
                        if (this.isProductChoosen(product, request, session)) {
                                // Then add product's total price
-                               this.getLogger().debug(MessageFormat.format("Calling getTotalPositionPriceFromRequestSession({0},request,session) ...", product.getId())); //NOI18N
+                               this.getLogger().debug(MessageFormat.format("Calling getTotalPositionPriceFromRequestSession({0},request,session) ...", product.getItemId())); //NOI18N
                                totalPrice += this.getTotalPositionPriceFromRequestSession(product, request, session);
                        }
-                       this.getLogger().debug(MessageFormat.format("product={0},totalPrice={1}", product.getId(), totalPrice)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},totalPrice={1}", product.getItemId(), totalPrice)); //NOI18N
                }
 
                // Trace message
@@ -279,7 +279,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (session == null) {
@@ -320,7 +320,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (request == null) {
@@ -360,7 +360,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (session == null) {
@@ -374,7 +374,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Is the object null?
                if (object == null) {
                        // Not found
-                       this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getId())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Returning empty string for product={0} ...", product.getItemId())); //NOI18N
                        return ""; //NOI18N
                }
 
@@ -442,7 +442,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (request == null) {
@@ -454,9 +454,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get element
-               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getId(), request, session)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getItemId(), request, session)); //NOI18N
                String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getId(), choosen)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getItemId(), choosen)); //NOI18N
 
                // Must not be null
                assert(choosen instanceof String): "choosen is null"; //NOI18N
@@ -469,7 +469,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Get amount
                String amount = this.handleAmountFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getId(), amount)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getItemId(), amount)); //NOI18N
 
                // Must not be null
                assert(amount instanceof String): "amount is null"; //NOI18N
@@ -497,7 +497,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
 
                // Is it null?
-               if (product == null) {
+               if (null == product) {
                        // Should not be null
                        throw new NullPointerException("product is null"); //NOI18N
                }
@@ -606,7 +606,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (request == null) {
@@ -618,9 +618,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get choosen
-               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getId(), request, session)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getItemId(), request, session)); //NOI18N
                String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getId(), choosen)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getItemId(), choosen)); //NOI18N
 
                // Must not be null
                assert(choosen instanceof String): "choosen is null"; //NOI18N
@@ -628,13 +628,13 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Is it set?
                if (choosen.isEmpty()) {
                        // Is empty
-                       this.getLogger().debug(MessageFormat.format("product={0},choosen={1} - returning zero ...", product.getId(), choosen)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},choosen={1} - returning zero ...", product.getItemId(), choosen)); //NOI18N
                        return 0.00f;
                }
 
                // Get amount
                String amount = this.handleAmountFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getId(), amount)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},amount={1}", product.getItemId(), amount)); //NOI18N
 
                // Must not be null
                assert(amount instanceof String): "amount is null"; //NOI18N
@@ -642,7 +642,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Is it empty?
                if (amount.isEmpty() || "0".equals(amount)) { //NOI18N
                        // Is empty
-                       this.getLogger().debug(MessageFormat.format("product={0},amount={1} - returning zero ...", product.getId(), amount)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("product={0},amount={1} - returning zero ...", product.getItemId(), amount)); //NOI18N
                        return 0.00f;
                }
 
@@ -662,7 +662,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                float price = (product.getPrice() * value);
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0},price={1} - EXIT!", product.getId(), price)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("product={0},price={1} - EXIT!", product.getItemId(), price)); //NOI18N
 
                // Then multiply it with price
                return price;
@@ -682,7 +682,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (request == null) {
@@ -703,12 +703,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                } else if (this.handleChooseFromRequestSession(product, request, session).isEmpty()) {
                        // Not choosen
                        this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
-                       this.getLogger().debug(MessageFormat.format("Unsetting for product={0} in session, returning zero ...", product.getId())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Unsetting for product={0} in session, returning zero ...", product.getItemId())); //NOI18N
                        return "0"; //NOI18N
                }
 
                // Get attribute from request
-               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_AMOUNT, product.getId()));
+               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_AMOUNT, product.getItemId()));
 
                // Is it set?
                if (object instanceof String) {
@@ -749,7 +749,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (request == null) {
@@ -761,9 +761,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Get choosen
-               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getId(), request, session)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Calling handleChooseFromRequestSession({0},{1},{2}) ...", product.getItemId(), request, session)); //NOI18N
                String choosen = this.handleChooseFromRequestSession(product, request, session);
-               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getId(), choosen)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},choosen={1}", product.getItemId(), choosen)); //NOI18N
 
                // Must not be null
                assert(choosen instanceof String): "choosen is null"; //NOI18N
@@ -832,7 +832,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (session == null) {
@@ -841,7 +841,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getId())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Marking product={0} as choosen.", product.getItemId())); //NOI18N
                this.setValueInSession(product, session, HTTP_PARAM_ITEM_ID, "1"); //NOI18N
 
                // Trace message
@@ -860,7 +860,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (session == null) {
@@ -869,7 +869,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Marking product={0} as ordered.", product.getId())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Marking product={0} as ordered.", product.getItemId())); //NOI18N
                this.setValueInSession(product, session, SESSION_ORDERED, "true"); //NOI18N
 
                // Trace message
@@ -909,7 +909,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (session == null) {
@@ -918,7 +918,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as choosen.", product.getId())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as choosen.", product.getItemId())); //NOI18N
                this.clearSessionAttribute(product, session, HTTP_PARAM_ITEM_ID);
 
                // Trace message
@@ -937,7 +937,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1} - CALLED!", product, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (session == null) {
@@ -946,7 +946,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                }
 
                // Mark it as ordered by setting flag
-               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as ordered.", product.getId())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Unmarking product={0} as ordered.", product.getItemId())); //NOI18N
                this.clearSessionAttribute(product, session, SESSION_ORDERED);
 
                // Trace message
@@ -965,7 +965,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("produce={0},parameter={1},session={2} - CALLED!", product, parameter, session)); //NOI18N
 
                // Clear in session
-               this.getLogger().debug(MessageFormat.format("Clearing product={0},parameter={1} ...", product.getId(), parameter)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Clearing product={0},parameter={1} ...", product.getItemId(), parameter)); //NOI18N
                this.setValueInSession(product, session, parameter, null);
 
                // Trace message
@@ -985,9 +985,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1},attribute={2} - CALLED!", product, session, attribute)); //NOI18N
 
                // Init variable
-               Object value = this.getValueFromSession(session, String.format(HTTP_PARAM_MASK, attribute, product.getId()));
+               Object value = this.getValueFromSession(session, String.format(HTTP_PARAM_MASK, attribute, product.getItemId()));
                
-               this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getId(), attribute, value)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},attribute={1},value={2}", product.getItemId(), attribute, value)); //NOI18N
 
                // Trace message
                this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
@@ -1035,7 +1035,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N
 
                // Is product and session set?
-               if (product == null) {
+               if (null == product) {
                        // Not set
                        throw new NullPointerException("product is null"); //NOI18N
                } else if (request == null) {
@@ -1052,26 +1052,26 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                // Check request method
                if (!"POST".equals(request.getMethod())) { //NOI18N
                        // Not POST, so get from session
-                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getId(), session)); //NOI18N
+                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getItemId(), session)); //NOI18N
                        return this.getChooseFromSession(product, session);
                } else if (this.isProductOrdered(product, session)) {
                        // Product is ordered
-                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getId(), session)); //NOI18N
+                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getItemId(), session)); //NOI18N
                        return this.getChooseFromSession(product, session);
                } else if (!this.getChooseFromSession(product, session).isEmpty()) {
                        // Found in session
-                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getId(), session)); //NOI18N
+                       this.getLogger().trace(MessageFormat.format("Calling this.getChooseFromSession({0},{1}) ... - EXIT!", product.getItemId(), session)); //NOI18N
                        return this.getChooseFromSession(product, session);
                }
 
                // Get reqzest element
-               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_ITEM_ID, product.getId()));
-               this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getId(), object)); //NOI18N
+               object = request.getParameter(String.format(HTTP_PARAM_MASK, HTTP_PARAM_ITEM_ID, product.getItemId()));
+               this.getLogger().debug(MessageFormat.format("product={0},object={1}", product.getItemId(), object)); //NOI18N
 
                // Is it null?
                if (object == null) {
                        // Unset session
-                       this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getId())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Unsetting session for product={0} ...", product.getItemId())); //NOI18N
                        this.clearSessionAttribute(product, session, HTTP_PARAM_ITEM_ID);
                        this.clearSessionAttribute(product, session, HTTP_PARAM_AMOUNT);
 
@@ -1083,7 +1083,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.setValueInSession(product, session, HTTP_PARAM_ITEM_ID, object);
 
                // Cast to string and return it
-               this.getLogger().debug(MessageFormat.format("product={0} - Returning {1} ...", product.getId(), object)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0} - Returning {1} ...", product.getItemId(), object)); //NOI18N
                return (String) object;
        }
 
@@ -1132,7 +1132,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
 
                // Get session
                Object isOrdered = this.getValueFromSession(product, session, SESSION_ORDERED);
-               this.getLogger().debug(MessageFormat.format("product={0},isOrdered={1}", product.getId(), isOrdered)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("product={0},isOrdered={1}", product.getItemId(), isOrdered)); //NOI18N
 
                // Return result
                return ("true".equals(isOrdered)); //NOI18N
@@ -1151,8 +1151,8 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0},session={1},keyPart={2},value={3} - CALLED!", product, session, keyPart, value)); //NOI18N
 
                // Set it synced
-               this.getLogger().debug(MessageFormat.format("Setting value={0} for product={1},keyPart={2}", value, product.getId(), keyPart)); //NOI18N
-               this.setValueInSession(session, String.format(HTTP_PARAM_MASK, keyPart, product.getId()), value);
+               this.getLogger().debug(MessageFormat.format("Setting value={0} for product={1},keyPart={2}", value, product.getItemId(), keyPart)); //NOI18N
+               this.setValueInSession(session, String.format(HTTP_PARAM_MASK, keyPart, product.getItemId()), value);
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
@@ -1192,7 +1192,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                        Product product = iterator.next();
 
                        // Output data
-                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getId(), product.getTitle(), product.getPrice())); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getItemId(), product.getTitle(), product.getPrice())); //NOI18N
                }
 
                // Generate fake Customer instance
@@ -1422,7 +1422,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
 
                // product must not be null
-               if (product == null) {
+               if (null == product) {
                        // Abort here
                        throw new NullPointerException("product is null"); //NOI18N
                }
index f41837d2cca55bd7a39b7ba7bba4cbc524fe69b7..79633d7b160369a4ca40c1e8d20b567494a34be7 100644 (file)
  */
 package org.mxchange.pizzaapplication.basket;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
 import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.database.frontend.basket.BasketDatabaseFrontend;
 import org.mxchange.pizzaapplication.database.frontend.basket.BasketFrontend;
@@ -38,6 +43,11 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
         */
        private static final long serialVersionUID = 784396762230845717L;
 
+       /**
+        * Session id assigned with this basket, or any other unique identifier
+        */
+       private String sessionId;
+
        /**
         * Protected constructor with session instance
         * 
@@ -59,12 +69,12 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
        }
 
        @Override
-       public void addItem (final T item) {
+       public void addItem (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace call
                this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
 
                // item must not be null
-               if (item == null) {
+               if (null == item) {
                        // Then abort here
                        throw new NullPointerException("item is null"); //NOI18N
                } else if (this.isItemAdded(item)) {
@@ -73,36 +83,36 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
                }
 
                // Add item to database
-               ((BasketFrontend) this.getFrontend()).addItem(item);
+               ((BasketFrontend) this.getFrontend()).addItem(item, this.getSessionId());
 
                // Trace call
                this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        @Override
-       public AddableBasketItem getItem (final Product product) {
+       public AddableBasketItem getItem (final Product product) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
 
                // product must not be null
-               if (product == null) {
+               if (null == product) {
                        // Abort here
                        throw new NullPointerException("product is null"); //NOI18N
                }
 
                // Debug message
-               this.getLogger().debug("Product " + product.getTitle() +  " has id " + product.getId()); //NOI18N
+               this.getLogger().debug(MessageFormat.format("Product {0} has id {1},frontend={2}", product.getTitle(), product.getItemId(), this.getFrontend())); //NOI18N
 
                // Get item instance from map by product's id number (both are the same)
-               AddableBasketItem item = ((BasketFrontend) this.getFrontend()).getItem(product);
+               AddableBasketItem item = ((BasketFrontend) this.getFrontend()).getItem(product, this.getSessionId());
 
                // Is it null?
-               if (item == null) {
+               if (null == item) {
                        // Trace message
                        this.getLogger().trace("item=null - EXIT!"); //NOI18N
                } else {
                        // Trace message
-                       this.getLogger().trace(MessageFormat.format("item={0} with id={1},amount={2} - EXIT!", item, item.getId(), item.getAmount())); //NOI18N
+                       this.getLogger().trace(MessageFormat.format("item={0} with id={1},amount={2} - EXIT!", item, item.getItemId(), item.getAmount())); //NOI18N
                }
 
                // Return it
@@ -110,18 +120,18 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
        }
 
        @Override
-       public boolean isItemAdded (final T item) {
+       public boolean isItemAdded (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace call
                this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
 
                // item must not be null
-               if (item == null) {
+               if (null == item) {
                        // Then abort here
                        throw new NullPointerException("item is null"); //NOI18N
                }
 
                // Call map's method
-               boolean isAdded = ((BasketFrontend) this.getFrontend()).isItemAdded(item);
+               boolean isAdded = ((BasketFrontend) this.getFrontend()).isItemAdded(item, this.getSessionId());
 
                // Trace message
                this.getLogger().trace(MessageFormat.format("isAdded={0} - EXIT!", isAdded)); //NOI18N
@@ -129,4 +139,45 @@ public class BaseBasket<T extends AddableBasketItem> extends BaseFrameworkSystem
                // Return it
                return isAdded;
        }
+
+       /**
+        * Setter for session id
+        *
+        * @param sessionId Session id
+        */
+       protected final void setSessionId (final String sessionId) {
+               this.sessionId = sessionId;
+       }
+
+       /**
+        * Getter for session id
+        *
+        * @return Session id
+        */
+       protected final String getSessionId () {
+               return this.sessionId;
+       }
+
+       /**
+        * Called when fields are set on deserialization
+        *
+        * @param in Object input stream
+        * @throws IOException If any IO error occurs
+        * @throws ClassNotFoundException If the class is not found
+        */
+       private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("in={0} - CALLED!", in));
+
+               try {
+                       // Init frontend
+                       BasketFrontend frontend = new BasketDatabaseFrontend();
+
+                       // Set it here
+                       this.setFrontend(frontend);
+               } catch (final UnsupportedDatabaseBackendException | SQLException ex) {
+                       // Continue to throw
+                       throw new IOException(ex);
+               }
+       }
 }
index fa7d7efd9f54bf852e7279e61f5d37396ace3f77..5f63d07e2a4e39b6e072a256838c34bfec37491e 100644 (file)
  */
 package org.mxchange.pizzaapplication.basket;
 
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
 import org.mxchange.jcore.FrameworkInterface;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.pizzaapplication.item.AddableBasketItem;
 import org.mxchange.pizzaapplication.product.Product;
 
@@ -31,8 +36,15 @@ public interface Basket<T extends AddableBasketItem> extends FrameworkInterface
        /**
         * Adds given item instance to this basket
         * @param item Item instance to add
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
         */
-       public void addItem (final T item);
+       public void addItem (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 
        /**
         * Checks whether the given item as already been added. Mostly
@@ -41,14 +53,28 @@ public interface Basket<T extends AddableBasketItem> extends FrameworkInterface
         *
         * @param item Item instance to check
         * @return Whether the given item has been found
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
         */
-       public boolean isItemAdded (final T item);
+       public boolean isItemAdded (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 
        /**
         * Returns an item for given product instance or null if not found.
         * 
         * @param product Product instance
         * @return Item instance or null
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
         */
-       public AddableBasketItem getItem (final Product product);
+       public AddableBasketItem getItem (final Product product) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 }
index ae59e6571e527e6d20675bf84a72d28d1e5a8094..e69bc5e4ddc87e1a9b9455589a91afadcf6b050d 100644 (file)
@@ -17,7 +17,9 @@
 package org.mxchange.pizzaapplication.basket.item;
 
 import java.sql.SQLException;
+import java.text.MessageFormat;
 import javax.servlet.http.HttpSession;
+import org.mxchange.jcore.BaseFrameworkSystem;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.basket.BaseBasket;
 import org.mxchange.pizzaapplication.basket.Basket;
@@ -45,13 +47,19 @@ public class ItemBasket<T extends AddableBasketItem> extends BaseBasket<T> imple
         */
        @SuppressWarnings ("unchecked")
        public final static Basket<AddableBasketItem> getInstance (final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException {
+               // Trace message
+               BaseFrameworkSystem.getInstance().getLogger().trace(MessageFormat.format("session={0} - CALLED!", session)); //NOI18N
+
                // Get instance
                Basket<AddableBasketItem> basket = (Basket<AddableBasketItem>) session.getAttribute("basket"); //NOI18N
 
+               // Debug message
+               BaseFrameworkSystem.getInstance().getLogger().debug(MessageFormat.format("basket={0}", basket));
+
                // Is the basket already created?
-               if (!(basket instanceof BaseBasket)) {
+               if (!(basket instanceof Basket)) {
                        // Not yet, so create it
-                       basket = new ItemBasket<>();
+                       basket = new ItemBasket<>(session);
 
                        // Add it in session
                        session.setAttribute("basket", basket); //NOI18N
@@ -63,9 +71,23 @@ public class ItemBasket<T extends AddableBasketItem> extends BaseBasket<T> imple
 
        /**
         * Default constructor to be able to throw exceptions from super constructor
+        *
+        * @param session HttpSession instance
         */
-       private ItemBasket () throws UnsupportedDatabaseBackendException, SQLException {
+       private ItemBasket (final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException {
+               // Call super constructor
+               super();
+
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().trace(MessageFormat.format("session={0} - CALLED!", session)); //NOI18N
+
+               // Session must be set
+               if (null == session) {
+                       // Session is null
+                       throw new NullPointerException("session is null");
+               }
+
+               // Set session id here
+               this.setSessionId(session.getId());
        }
 }
index 89c1db75ab747d595d992744621d0290363bf169..35b68a9fdfd70996f825a6168f113a4ae6cc88da 100644 (file)
@@ -31,10 +31,10 @@ public class BaseCategory extends BaseFrameworkSystem implements Category {
        /**
         * Id number of category
         */
-       private Long id;
+       private Long categoryId;
 
        /**
-        * Parent category id
+        * Parent category categoryId
         */
        private Long parent;
 
@@ -47,11 +47,11 @@ public class BaseCategory extends BaseFrameworkSystem implements Category {
         * Constructor which accepts all database fields
         * @param id Id number of database record
         * @param title Category title
-        * @param parent Parent id
+        * @param parent Parent categoryId
         */
        protected BaseCategory (final Long id, final String title, final Long parent) {
                // Set all here
-               this.setId(id);
+               this.setCategoryId(id);
                this.setTitle(title);
                this.setParent(parent);
        }
@@ -79,18 +79,18 @@ public class BaseCategory extends BaseFrameworkSystem implements Category {
                }
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("this.id={0},category.id={1}", this.getId(), category.getId())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("this.id={0},category.id={1}", this.getCategoryId(), category.getCategoryId())); //NOI18N
 
-               // Is the id the same?
-               if (Objects.equals(this.getId(), category.getId())) {
-                       // Same id, means same category
+               // Is the categoryId the same?
+               if (Objects.equals(this.getCategoryId(), category.getCategoryId())) {
+                       // Same categoryId, means same category
                        return 0;
-               } else if (this.getId() > category.getId()) {
-                       // This id is larger than compared to
+               } else if (this.getCategoryId() > category.getCategoryId()) {
+                       // This categoryId is larger than compared to
                        return -1;
                }
 
-               // The other id is larger
+               // The other categoryId is larger
                return 1;
        }
 
@@ -110,24 +110,24 @@ public class BaseCategory extends BaseFrameworkSystem implements Category {
 
        /**
         * Id number of category
-        * @return the id
+        * @return the categoryId
         */
        @Override
-       public final Long getId () {
-               return this.id;
+       public final Long getCategoryId () {
+               return this.categoryId;
        }
 
        /**
         * Id number of category
-        * @param id the id to set
+        * @param categoryId the categoryId to set
         */
        @Override
-       public final void setId (final Long id) {
-               this.id = id;
+       public final void setCategoryId (final Long categoryId) {
+               this.categoryId = categoryId;
        }
 
        /**
-        * Parent category id
+        * Parent category categoryId
         * @return the parent
         */
        @Override
@@ -136,7 +136,7 @@ public class BaseCategory extends BaseFrameworkSystem implements Category {
        }
 
        /**
-        * Parent category id
+        * Parent category categoryId
         * @param parent the parent to set
         */
        @Override
index 16b38a6472cf853d001dc46386b6558ccb1b9aae..a4cfc3184f0bcbd61de86aacc70ce7311af70ee3 100644 (file)
@@ -30,13 +30,13 @@ public interface Category extends Storeable, Comparable<Category> {
         * Id number of category
         * @return the id
         */
-       public Long getId ();
+       public Long getCategoryId ();
 
        /**
         * Id number of category
         * @param id the id to set
         */
-       public void setId (final Long id);
+       public void setCategoryId (final Long id);
 
        /**
         * Parent category id
diff --git a/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java
new file mode 100644 (file)
index 0000000..58a6dd5
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.database.basket;
+
+/**
+ * Constants for table "basket".
+ *
+ * @author Roland Haeder
+ */
+public final class BasketDatabaseConstants {
+       /**
+        * Column for id
+        */
+       public static final String COLUMN_ID = "id"; //NOI18N
+
+       /**
+        * Column for amount
+        */
+       public static final String COLUMN_AMOUNT = "amount"; //NOI18N
+
+       /**
+        * Column for product id
+        */
+       public static final String COLUMN_ITEM_ID = "item_id"; //NOI18N
+
+       /**
+        * Column for product type
+        */
+       public static final String COLUMN_PRODUCT_TYPE = "item_type"; //NOI18N
+
+       /**
+        * Column for session id or any unique identifier
+        */
+       public static final String COLUMN_SESSION_ID = "session_id"; //NOI18N
+
+       /**
+        * No instance from this class
+        */
+       private BasketDatabaseConstants () {
+       }
+}
index cab19857ebccd171ebfddc2156616f4ec465da8b..4fde31e2af05fcdfcaf48708d8fdb5f59489aa5c 100644 (file)
@@ -25,7 +25,7 @@ public final class PizzaCategoryDatabaseConstants {
        /**
         * Column name for "id"
         */
-       public static final String COLUMN_ID = "id"; //NOI18N
+       public static final String COLUMN_ID = "category_id"; //NOI18N
 
        /**
         * Column name for "parent"
index 60aa675178b626f939b46ac9a658cb6a9f245fd3..e261e63de253a4b7975b87280897e6e1b0d49d6f 100644 (file)
@@ -20,11 +20,19 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
+import java.util.Iterator;
 import java.util.Map;
+import org.mxchange.jcore.criteria.searchable.SearchCriteria;
+import org.mxchange.jcore.criteria.searchable.SearchableCriteria;
 import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend;
+import org.mxchange.jcore.database.result.Result;
 import org.mxchange.jcore.database.storage.Storeable;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
+import org.mxchange.pizzaapplication.database.basket.BasketDatabaseConstants;
 import org.mxchange.pizzaapplication.item.AddableBasketItem;
+import org.mxchange.pizzaapplication.item.basket.BasketItem;
 import org.mxchange.pizzaapplication.product.Product;
 
 /**
@@ -51,8 +59,40 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask
        }
 
        @Override
-       public void addItem (final AddableBasketItem item) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       public void addItem (final AddableBasketItem item, final String sessionId) throws SQLException, IOException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("item={0},sessionId={1} - CALLED!", item, sessionId));
+
+               // Both must not be null
+               if (null == item) {
+                       // Product is null
+                       throw new NullPointerException("item is null"); //NOI18N
+               } else if (null == sessionId) {
+                       // Session id is null
+                       throw new NullPointerException("sessionId is null"); //NOI18N
+               } else if (sessionId.isEmpty()) {
+                       // Session id should not be empty
+                       throw new IllegalArgumentException("sessionId is empty."); //NOI18N
+               }
+
+               // Clear previous data set
+               this.clearDataSet();
+
+               // Add item it and session
+               this.addToDataSet(BasketDatabaseConstants.COLUMN_ITEM_ID, item.getItemId());
+               this.addToDataSet(BasketDatabaseConstants.COLUMN_SESSION_ID, sessionId);
+               this.addToDataSet(BasketDatabaseConstants.COLUMN_AMOUNT, item.getAmount());
+               this.addToDataSet(BasketDatabaseConstants.COLUMN_PRODUCT_TYPE, item.getItemType());
+
+               // Handle this over to the backend
+               // @todo Nothing is done yet!
+               Result<? extends Storeable> result = this.doInsertDataSet();
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
@@ -105,26 +145,230 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask
 
        @Override
        public String getIdName () {
-               throw new UnsupportedOperationException("Not supported yet.");
+               return BasketDatabaseConstants.COLUMN_ID;
        }
 
        @Override
-       public AddableBasketItem getItem (final Product product) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       public AddableBasketItem getItem (final Product product, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},sessionId={1} - CALLED!", product, sessionId)); //NOI18N
+
+               // Now search for it
+               Result<? extends Storeable> result = this.getResultFromProduct(product, sessionId);
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("result({0})={1}", result.size(), result)); //NOI18N
+
+               // Init item variable
+               AddableBasketItem item = null;
+
+               // Was an entry found?
+               if (result.hasNext()) {
+                       // Found one entry
+                       Storeable storeable = result.next();
+
+                       // Debug message
+                       this.getLogger().debug(MessageFormat.format("storeable={0}", storeable)); //NOI18N
+
+                       // Is it instance of Category?
+                       if (storeable instanceof AddableBasketItem) {
+                               // Then cast it
+                               item = (AddableBasketItem) storeable;
+                       }
+               }
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("item={0} - EXIT!", item)); //NOI18N
+
+               // Return item
+               return item;
        }
 
+/*
+               // Clear data set
+               this.clearDataSet();
+
+               // Add data to set
+               this.addToDataSet(BasketDatabaseConstants.COLUMN_ITEM_ID, id);
+               this.addToDataSet(BasketDatabaseConstants.COLUMN_SESSION_ID, sessionId);
+*/
+
        @Override
        public Storeable getStoreableAtRow (final int rowIndex) {
-               throw new UnsupportedOperationException("Not supported yet: rowIndex=" + rowIndex);
+               throw new UnsupportedOperationException(MessageFormat.format("Not supported yet: rowIndex={0}", rowIndex));
        }
 
        @Override
-       public boolean isItemAdded (final AddableBasketItem item) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       public boolean isItemAdded (final AddableBasketItem item, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("item={0},sessionId={1} - CALLED!", item, sessionId)); //NOI18N
+
+               // Get result back
+               Result<? extends Storeable> result = this.getResultFromItem(item, sessionId);
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("result.hasNext()={0} - EXIT!", result.hasNext())); //NOI18N
+
+               // Return hasNext()
+               return result.hasNext();
        }
 
        @Override
        public Storeable toStoreable (final Map<String, String> map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-               throw new UnsupportedOperationException("Not supported yet: map=" + map);
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("map={0} - CALLED!", map)); //NOI18N
+
+               // Is map null?
+               if (map == null) {
+                       // Is null
+                       throw new NullPointerException("map is null"); //NOI18N
+               } else if (map.isEmpty()) {
+                       // Map is empty
+                       throw new IllegalArgumentException("map is empty."); //NOI18N
+               }
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("Has to handle {0} entries", map.size())); //NOI18N
+
+               // Get iterator on all entries
+               Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
+
+               // Init object instance
+               Storeable instance = new BasketItem();
+
+               // Iterate over all
+               while (iterator.hasNext()) {
+                       // Get next entry
+                       Map.Entry<String, String> entry = iterator.next();
+
+                       // Debug message
+                       this.getLogger().debug(MessageFormat.format("entry:{0}={1}", entry.getKey(), entry.getValue())); //NOI18N
+
+                       // Try to set value
+                       instance.setValueFromColumn(entry.getKey(), entry.getValue());
+               }
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("instance={0} - EXIT!", instance)); //NOI18N
+
+               // Return it
+               return instance;
+       }
+
+       /**
+        * Some "getter" for a result instance from given product and session id
+        *
+        * @param product Product instance
+        * @param sessionId Session id or any unique identifier
+        * @return Result instance
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       private Result<? extends Storeable> getResultFromProduct (final Product product, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0},sessionId={1} - CALLED!", product, sessionId)); //NOI18N
+
+               // Both must not be null
+               if (null == product) {
+                       // Product is null
+                       throw new NullPointerException("product is null"); //NOI18N
+               } else if (null == sessionId) {
+                       // Session id is null
+                       throw new NullPointerException("sessionId is null"); //NOI18N
+               } else if (sessionId.isEmpty()) {
+                       // Session id should not be empty
+                       throw new IllegalArgumentException("sessionId is empty."); //NOI18N
+               }
+
+               // Get product id
+               Long id = product.getItemId();
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("id={0}", id)); //NOI18N
+
+               // Id should be > 0 here
+               assert(id > 0) : MessageFormat.format("Id for product {0} is below zero: {1}", product, id); //NOI18N
+
+               // Prepare search instance
+               SearchableCriteria criteria = new SearchCriteria();
+
+               // Add session id and product id and limit to 1
+               criteria.addCriteria(BasketDatabaseConstants.COLUMN_ITEM_ID, id);
+               criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, sessionId);
+               criteria.setLimit(1);
+
+               // Now search for it
+               Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
+
+               // Trace message
+               this.getLogger().debug(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N
+
+               // Return it
+               return result;
+       }
+
+       /**
+        * Some "getter" for a result instance from given item and session id
+        *
+        * @param item Item instance
+        * @param sessionId Session id or any unique identifier
+        * @return Result instance
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+        */
+       private Result<? extends Storeable> getResultFromItem (final AddableBasketItem item, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("item={0},sessionId={1} - CALLED!", item, sessionId)); //NOI18N
+
+               // Both must not be null
+               if (null == item) {
+                       // Item is null
+                       throw new NullPointerException("item is null"); //NOI18N
+               } else if (null == sessionId) {
+                       // Session id is null
+                       throw new NullPointerException("sessionId is null"); //NOI18N
+               } else if (sessionId.isEmpty()) {
+                       // Session id should not be empty
+                       throw new IllegalArgumentException("sessionId is empty."); //NOI18N
+               }
+
+               // Get product id
+               Long id = item.getItemId();
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("id={0}", id)); //NOI18N
+
+               // Id should be > 0 here
+               assert(id > 0) : MessageFormat.format("Id for item {0} is below zero: {1}", item, id); //NOI18N
+
+               // Prepare search instance
+               SearchableCriteria criteria = new SearchCriteria();
+
+               // Add session id and product id and limit to 1
+               criteria.addCriteria(BasketDatabaseConstants.COLUMN_ITEM_ID, id);
+               criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, sessionId);
+               criteria.setLimit(1);
+
+               // Now search for it
+               Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
+
+               // Trace message
+               this.getLogger().debug(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N
+
+               // Return it
+               return result;
        }
 }
index 5a472e2a274e459d769aa93ad3308c83b5e0b919..323fae0a86052cf44b5840d8b33176daf2a4b17e 100644 (file)
  */
 package org.mxchange.pizzaapplication.database.frontend.basket;
 
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
 import org.mxchange.jcore.database.frontend.DatabaseFrontend;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.pizzaapplication.item.AddableBasketItem;
 import org.mxchange.pizzaapplication.product.Product;
 
@@ -31,22 +36,41 @@ public interface BasketFrontend extends DatabaseFrontend {
         * comes from product table.
         *
         * @param item Item instance to add
+        * @param sessionId Session id or any other unique identifier
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
         */
-       public void addItem (final AddableBasketItem item);
+       public void addItem (final AddableBasketItem item, final String sessionId) throws IOException, SQLException;
 
        /**
         * Gets an item instance for given Product instance
         *
         * @param product Prodduct instance
+        * @param sessionId Session id or any other unique identifier
         * @return An item instance
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
         */
-       public AddableBasketItem getItem (final Product product);
+       public AddableBasketItem getItem (final Product product, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 
        /**
         * Checks if given item instance is found in basket by its id number.
         *
         * @param item Item instance to check
+        * @param sessionId Session id or any other unique identifier
         * @return Whether the item is already added to the basket
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
+        * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If a corrupted database file was found
+        * @throws java.lang.NoSuchMethodException If a method was not found
+        * @throws java.lang.IllegalAccessException If the invoked method is not public
+        * @throws java.lang.reflect.InvocationTargetException If anything else happened?
         */
-       public boolean isItemAdded (final AddableBasketItem item);
+       public boolean isItemAdded (final AddableBasketItem item, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 }
index 29aa737c62aa64e96d2c87d22c880047dd2373b4..f6d8b3805a6c88feb4715c79310ea6d94f4d2a7c 100644 (file)
@@ -34,7 +34,8 @@ import org.mxchange.pizzaapplication.product.Product;
 public interface CategoryFrontend extends DatabaseFrontend {
 
        /**
-        * Adds given category title as new category, parent may be null if not selected.
+        * Adds given category title as new category, parent may be null if not
+        * selected.
         *
         * @param title Title of category
         * @param parent Parent id or null if not selected
index 6f98dd40a4701beeebfde441bda8f43a53ee8acf..32602a8d7e6195f8976a433d302f16c1d8ec737e 100644 (file)
@@ -43,8 +43,10 @@ import org.mxchange.pizzaapplication.product.Product;
  * @author Roland Haeder
  */
 public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implements CategoryFrontend {
+
        /**
         * Default constrcutor
+        *
         * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the configured backend is not supported
         * @throws java.sql.SQLException If any SQL error occurs
         */
@@ -60,7 +62,8 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen
        }
 
        /**
-        * Adds given category title as new category, parent may be null if not selected.
+        * Adds given category title as new category, parent may be null if not
+        * selected.
         *
         * @param title Title of category
         * @param parent Parent id or null if not selected
@@ -96,6 +99,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen
 
        /**
         * Shuts down the database layer
+        *
         * @throws java.sql.SQLException If an SQL error occurs
         * @throws java.io.IOException If any IO error occurs
         */
@@ -172,58 +176,58 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen
        public Category getCategory (final Product product) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                // Trace message
                this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
-               
+
                // product must not be null
-               if (product == null) {
+               if (null == product) {
                        // Abort here
                        throw new NullPointerException("product is null"); //NOI18N
                }
-               
+
                // Get category id from it
                Long id = product.getCategory();
-               
+
                // Debug message
                this.getLogger().debug(MessageFormat.format("id={0}", id)); //NOI18N
-               
+
                // It should be >0 here
-               assert(id > 0) : MessageFormat.format("id={0} must be larger zero", id); //NOI18N
-               
+               assert (id > 0) : MessageFormat.format("id={0} must be larger zero", id); //NOI18N
+
                // Then construct a search instance
                SearchableCriteria criteria = new SearchCriteria();
-               
+
                // Add id to it
                criteria.addCriteria(PizzaCategoryDatabaseConstants.COLUMN_ID, id);
-               
+
                // Only one entry is find
                criteria.setLimit(1);
-               
+
                // Run it on backend
                Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
-               
+
                // Debug log
                this.getLogger().debug(MessageFormat.format("result({0})={1}", result, result.size())); //NOI18N
-               
+
                // Init category instance
                Category category = null;
-               
+
                // Is there one entry?
                if (result.hasNext()) {
                        // Read result from it
                        Storeable storeable = result.next();
-                       
+
                        // Debug message
                        this.getLogger().debug(MessageFormat.format("storeable={0}", storeable)); //NOI18N
-                       
+
                        // Is it instance of Category?
                        if (storeable instanceof Category) {
                                // Then cast it
                                category = (Category) storeable;
                        }
                }
-               
+
                // Trace message
                this.getLogger().trace(MessageFormat.format("category={0} - EXIT!", category)); //NOI18N
-               
+
                // Return it
                return category;
        }
@@ -321,9 +325,11 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen
        }
 
        /**
-        * Converts the given map into a Storeable instance, depending on which class implements it. All
-        * keys are being interpreted as class fields/attributes and their respective setters are being searched for. As
-        * this method may fail to find one or access it, this method throws some exception.
+        * Converts the given map into a Storeable instance, depending on which
+        * class implements it. All keys are being interpreted as class
+        * fields/attributes and their respective setters are being searched for. As
+        * this method may fail to find one or access it, this method throws some
+        * exception.
         *
         * @param map Map instance to convert to Storeable
         * @return An instance of a Storeable implementation
index 8ac757b2c3340bfcc2b1ea9ceb444a16be313684..55729e7fae479d263aad88717c134580f3b78de5 100644 (file)
@@ -218,7 +218,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
        @Override
        public String getIdName () {
                // Return column id
-               return PizzaProductDatabaseConstants.COLUMN_ID;
+               return PizzaProductDatabaseConstants.COLUMN_ITEM_ID;
        }
 
        /**
@@ -242,7 +242,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
                // "Walk" through all entries
                while (resultSet.next()) {
                        // Get id, title and parent id
-                       Long id = resultSet.getLong(PizzaProductDatabaseConstants.COLUMN_ID);
+                       Long id = resultSet.getLong(PizzaProductDatabaseConstants.COLUMN_ITEM_ID);
                        String title = resultSet.getString(PizzaProductDatabaseConstants.COLUMN_TITLE);
                        Float price = resultSet.getFloat(PizzaProductDatabaseConstants.COLUMN_PRICE);
                        Long category = resultSet.getLong(PizzaProductDatabaseConstants.COLUMN_CATEGORY);
index 97848c1d084f0a43447d4ff49be5a9090567f356..d10a80e49af2f9fea819d5f85aba90f480043902 100644 (file)
@@ -33,9 +33,9 @@ public final class PizzaProductDatabaseConstants {
        public static final String COLUMN_CATEGORY = "category"; //NOI18N
 
        /**
-        * Column name for "id"
+        * Column name for "item_id"
         */
-       public static final String COLUMN_ID = "id"; //NOI18N
+       public static final String COLUMN_ITEM_ID = "item_id"; //NOI18N
 
        /**
         * Column name for "price"
index 065303184ec1c106ffc4fc04e8078eb8f061c86b..7b20ca2fa035bb9973d02e02a1f3d7af9361122a 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.pizzaapplication.filter.servlet.basket;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
 import javax.servlet.Filter;
@@ -26,6 +27,8 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.pizzaapplication.basket.Basket;
 import org.mxchange.pizzaapplication.basket.item.ItemBasket;
@@ -94,25 +97,25 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter {
 
                        // Get basket instance
                        basket = ItemBasket.getInstance(session);
-               } catch (final UnsupportedDatabaseBackendException | SQLException ex) {
-                       // Continue to throw
-                       throw new ServletException(ex);
-               }
 
-               // Is the item already added?
-               if ((item.getAmount() == null) || (item.getAmount() == 0)) {
-                       // Debug message
-                       this.getLogger().debug("Amount for item " + item + " is null");
+                       // Is the item already added?
+                       if ((item.getAmount() == null) || (item.getAmount() == 0)) {
+                               // Debug message
+                               this.getLogger().debug("Amount for item " + item + " is null");
 
-                       // Amount is not entered
-                       return;
-               } else if (basket.isItemAdded(item)) {
-                       // Yes, then throw exception here
-                       throw new ServletException(MessageFormat.format("item id={0} has already been added.", item.getId()));
-               }
+                               // Amount is not entered
+                               return;
+                       } else if (basket.isItemAdded(item)) {
+                               // Yes, then throw exception here
+                               throw new ServletException(MessageFormat.format("item id={0} has already been added.", item.getItemId()));
+                       }
 
-               // Register item with it
-               basket.addItem(item);
+                       // Register item with it
+                       basket.addItem(item);
+               } catch (final UnsupportedDatabaseBackendException | SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+                       // Continue to throw
+                       throw new ServletException(ex);
+               }
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
index 4c0acd383e037d6ca7e85a6d53214b466730098e..12e3346b10222496aaa88a2b62fe2d97e8a5771e 100644 (file)
  */
 package org.mxchange.pizzaapplication.item;
 
-import org.mxchange.jcore.FrameworkInterface;
+import org.mxchange.jcore.database.storage.Storeable;
 
 /**
  * An interface for addable basket items
  *
  * @author Roland Haeder
  */
-public interface AddableBasketItem extends FrameworkInterface {
+public interface AddableBasketItem extends Storeable, Comparable<AddableBasketItem> {
 
        /**
         * Item amount
@@ -38,22 +38,54 @@ public interface AddableBasketItem extends FrameworkInterface {
        public void setAmount (final Long amount);
 
        /**
+        * Entry id (from database backend)
         * @return the id
         */
        public Long getId ();
 
        /**
+        * Entry id (from database backend)
         * @param id the id to set
         */
        public void setId (final Long id);
 
+       /**
+        * @return the id
+        */
+       public Long getItemId ();
+
+       /**
+        * @param id the id to set
+        */
+       public void setItemId (final Long id);
+
        /**
         * @return the type
         */
-       public String getType ();
+       public String getItemType ();
 
        /**
         * @param type the type to set
         */
-       public void setType (final String type);
+       public void setItemType (final String type);
+
+       /**
+        * Session id
+        * @return the sessionId
+        */
+       public String getSessionId ();
+
+       /**
+        * Session id
+        * @param sessionId the sessionId to set
+        */
+       public void setSessionId (final String sessionId);
+
+       /**
+        * Compare method
+        * @param item Item to compare to
+        * @return Comparison value
+        */
+       @Override
+       public int compareTo (final AddableBasketItem item);
 }
index 33b6f1315f811407af37494a8eaf9403810b7657..7670ce41e1981340935403d7b5d01459d17354d1 100644 (file)
@@ -16,6 +16,9 @@
  */
 package org.mxchange.pizzaapplication.item;
 
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+import java.util.Objects;
 import org.mxchange.jcore.BaseFrameworkSystem;
 
 /**
@@ -23,6 +26,11 @@ import org.mxchange.jcore.BaseFrameworkSystem;
  * @author Roland Haeder
  */
 public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
+       /**
+        * Entry id (from database backend)
+        */
+       private Long id;
+
        /**
         * Item amount
         */
@@ -31,12 +39,43 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
        /**
         * Item id number
         */
-       private Long id;
+       private Long itemId;
 
        /**
         * Item type
         */
-       private String type;
+       private String itemType;
+
+       /**
+        * Session id
+        */
+       private String sessionId;
+
+       @Override
+       public int compareTo (final AddableBasketItem item) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
+               
+               // item should not be null
+               if (null == item) {
+                       throw new NullPointerException("item is null"); //NOI18N
+               }
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("this.id={0},item.id={1}", this.getItemId(), item.getItemId())); //NOI18N
+
+               // Is the id the same?
+               if (Objects.equals(this.getItemId(), item.getItemId())) {
+                       // Same id, means same item
+                       return 0;
+               } else if (this.getItemId() > item.getItemId()) {
+                       // This id is larger than compared to
+                       return -1;
+               }
+
+               // The other id is larger
+               return 1;
+       }
 
        /**
         * Item amount
@@ -57,6 +96,7 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
        }
 
        /**
+        * Entry id (from database backend)
         * @return the id
         */
        @Override
@@ -65,6 +105,7 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
        }
 
        /**
+        * Entry id (from database backend)
         * @param id the id to set
         */
        @Override
@@ -72,19 +113,80 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem {
                this.id = id;
        }
 
+       /**
+        * @return the id
+        */
+       @Override
+       public final Long getItemId () {
+               return this.itemId;
+       }
+
+       /**
+        * @param itemId the id to set
+        */
+       @Override
+       public final void setItemId( final Long itemId) {
+               this.itemId = itemId;
+       }
+
        /**
         * @return the type
         */
        @Override
-       public final String getType () {
-               return this.type;
+       public final String getItemType () {
+               return this.itemType;
+       }
+
+       /**
+        * @param itemType the type to set
+        */
+       @Override
+       public final void setItemType (final String itemType) {
+               this.itemType = itemType;
+       }
+
+       /**
+        * Session id
+        * @return the sessionId
+        */
+       @Override
+       public final String getSessionId () {
+               return this.sessionId;
        }
 
        /**
-        * @param type the type to set
+        * Session id
+        * @param sessionId the sessionId to set
         */
        @Override
-       public final void setType (final String type) {
-               this.type = type;
+       public final void setSessionId (final String sessionId) {
+               this.sessionId = sessionId;
+       }
+
+       @Override
+       public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N
+
+               // Call super method
+               Object value = this.getValueInStoreableFromColumn(this, "BaseItem", columnName); //NOI18N
+
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
+
+               // Return value
+               return value;
+       }
+
+       @Override
+       public void setValueFromColumn (final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("columnName={0},value={1} - CALLED!", columnName, value)); //NOI18N
+
+               // Call super method
+               this.setValueInStoreableFromColumn(this, "BaseItem", columnName, value); //NOI18N
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 }
index 40431736290b85c8ee863d754bdae07c6ef09dc2..0cc17af0bba6ee94c44cacb3cdbc400235dffc6a 100644 (file)
@@ -46,13 +46,13 @@ public class BasketItem extends BaseItem implements AddableBasketItem {
                this.getLogger().debug(MessageFormat.format("product={0} - CALLED!", product));
 
                // product must not be null
-               if (product == null) {
+               if (null == product) {
                        // Abort here
                        throw new NullPointerException("product is null");
                }
 
                // Copy all neccessary values
-               this.setId(product.getId());
-               this.setType("Product"); //NOI18N
+               this.setItemId(product.getItemId());
+               this.setItemType("Product"); //NOI18N
        }
 }
index 744efd9a84924939ed0300e5be59e5700bfbbc57..153dfd8a015fb410f0c586f85777a263d414896d 100644 (file)
@@ -26,9 +26,9 @@ public class BaseProduct extends BaseFrameworkSystem implements Product {
        private Long category;
 
        /**
-        * Id number of product
+        * Id number of product item
         */
-       private Long id;
+       private Long itemId;
 
        /**
         * Price of product
@@ -52,18 +52,18 @@ public class BaseProduct extends BaseFrameworkSystem implements Product {
                this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
                
                // category should not be null
-               if (product == null) {
+               if (null == product) {
                        throw new NullPointerException("product is null"); //NOI18N
                }
                
                // Debug message
-               this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getId(), product.getId())); //NOI18N
+               this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getItemId(), product.getItemId())); //NOI18N
                
                // Is the id the same?
-               if (Objects.equals(this.getId(), product.getId())) {
+               if (Objects.equals(this.getItemId(), product.getItemId())) {
                        // Same id, means same category
                        return 0;
-               } else if (this.getId() > product.getId()) {
+               } else if (this.getItemId() > product.getItemId()) {
                        // This id is larger than compared to
                        return 1;
                }
@@ -117,17 +117,17 @@ public class BaseProduct extends BaseFrameworkSystem implements Product {
         * @return the name
         */
        @Override
-       public final Long getId () {
-               return this.id;
+       public final Long getItemId () {
+               return this.itemId;
        }
 
        /**
         * Id number of product
-        * @param id the id number to set
+        * @param itemId the id number to set
         */
        @Override
-       public final void setId (final Long id) {
-               this.id = id;
+       public final void setItemId (final Long itemId) {
+               this.itemId = itemId;
        }
 
        /**
index 2ff49328480e41e2158ef8eb4e744a66cbe395be..c212df21d79a57b179472ca10bd16589376ea7f0 100644 (file)
@@ -29,13 +29,13 @@ public interface Product extends Storeable, Comparable<Product> {
         * 
         * @return Id number of product
         */
-       public Long getId ();
+       public Long getItemId ();
 
        /**
         * Id number of product
         * @param id the id number to set
         */
-       public void setId (final Long id);
+       public void setItemId (final Long id);
 
        /**
         * Getter for title.
index ebc40b6e4c9024af6d00157e5f14e673ba4c522f..82c43fa953a184fd45c53a6b97452bdc1a9b60cf 100644 (file)
@@ -46,7 +46,7 @@ public class PizzaProduct extends BaseProduct implements Product {
                this.getLogger().trace(MessageFormat.format("id={0},title={1},price={2},category={3},available={4} - CALLED!", id, title, price, category, available)); //NOI18N
 
                // Set all here
-               this.setId(id);
+               this.setItemId(id);
                this.setTitle(title);
                this.setPrice(price);
                this.setCategory(category);
index c34277d3a0fe124a2d08c86f9b0ada924759bb2c..e87695986f5225c8eb0cfeae055e273bccfe54c9 100644 (file)
@@ -61,7 +61,7 @@
                                                        <c:forEach var="category" items="<%=app.getCategories()%>">
                                                        <tr>
                                                                <td>
-                                                                       <input class="input" type="checkbox" name="<%=PizzaCategoryDatabaseConstants.COLUMN_ID%>[${category.getId()}]" value="1" />
+                                                                       <input class="input" type="checkbox" name="<%=PizzaCategoryDatabaseConstants.COLUMN_ID%>[${category.getCategoryId()}]" value="1" />
                                                                </td>
                                                                <td>
                                                                        ${category.decodedTitle()}
index e3515583b4008091602b08c75bdfaccda9379980..85006fcbe26d6692a540c8e9a112c765024380f9 100644 (file)
@@ -69,8 +69,8 @@
                                                        <c:forEach var="product" items="<%=app.getAllProducts()%>">
                                                        <tr>
                                                                <td>
-                                                                       ${product.getId()}:
-                                                                       <input class="input" type="checkbox" name="product[${product.getId()}]" value="1" />
+                                                                       ${product.getItemId()}:
+                                                                       <input class="input" type="checkbox" name="product[${product.getItemId()}]" value="1" />
                                                                </td>
                                                                <td>
                                                                        ${product.getTitle()}
index e6b2b617561b63fa8112475b448e4f05b1212860..e9013807a3406a90e7f921c2e46ef2012a85377e 100644 (file)
                                                        <tr>
                                                                <td class="table_data_column">
                                                                        <input class="submit" type="submit" name="add" value="Hinzuf&uuml;gen" />
-                                                                       <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getId()%>" />
+                                                                       <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getItemId()%>" />
                                                                        <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
                                                                </td>
                                                                <td class="table_data_column">
index bf2e0c5ab3306516363aa6224c19ccb76691dbce..ae4a587f732b5aaa1410e7fc05b53e9a9e475622 100644 (file)
@@ -71,7 +71,7 @@
                                <h:panelGrid class="table" columns="4">
                                        <h:column class="table_header_column">
                                                <h:commandButton action="#{path}/form_handler/add_item.jsp" class="submit" value="Hinzuf&uuml;gen" />
-                                               <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getId()%>" />
+                                               <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getItemId()%>" />
                                                <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
                                        </h:column>
                                        <h:column class="table_header_column">
index 9eac81d6a4482e9da6677ff4870a7bb384fe1623..39cbeab136eee8237e9a7865c60dd3c027db6017 100644 (file)
@@ -16,6 +16,6 @@
 
 <select class="select" name="category" size="1">
        <c:forEach var="category" items="<%=app.getCategories()%>">
-               <option value="${category.getId()}">${category.decodedTitle()}</option>
+               <option value="${category.getCategoryId()}">${category.decodedTitle()}</option>
        </c:forEach>
 </select>
index d04126375762f901393d1062ccd7a8f30d816832..2004c8833b5f2107b18fabebf710097bda8fe6ea 100644 (file)
@@ -17,6 +17,6 @@
 <select class="select" name="<%=PizzaCategoryDatabaseConstants.COLUMN_PARENT%>" size="1">
        <option value="">Ist oberste Kategorie</option>
        <c:forEach var="category" items="<%=app.getCategories()%>">
-               <option value="${category.getId()}">${category.decodedTitle()}</option>
+               <option value="${category.getCategoryId()}">${category.decodedTitle()}</option>
        </c:forEach>
 </select>