From: Roland Haeder Date: Wed, 26 Aug 2015 12:39:32 +0000 (+0200) Subject: Continued with project: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=aab62521c277a8269a690e2b8b2efcae8dd1730f;p=pizzaservice-war.git Continued with project: - 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 --- diff --git a/lib/jcore.jar b/lib/jcore.jar index b40acb87..03f80536 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java index 09993d40..37829105 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java @@ -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" diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index f1a8fd1f..459d6c7d 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -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 } diff --git a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java index f41837d2..79633d7b 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java @@ -16,10 +16,15 @@ */ 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 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 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 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 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 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); + } + } } diff --git a/src/java/org/mxchange/pizzaapplication/basket/Basket.java b/src/java/org/mxchange/pizzaapplication/basket/Basket.java index fa7d7efd..5f63d07e 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/Basket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/Basket.java @@ -16,7 +16,12 @@ */ 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 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 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; } diff --git a/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java b/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java index ae59e657..e69bc5e4 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java @@ -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 extends BaseBasket imple */ @SuppressWarnings ("unchecked") public final static Basket getInstance (final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException { + // Trace message + BaseFrameworkSystem.getInstance().getLogger().trace(MessageFormat.format("session={0} - CALLED!", session)); //NOI18N + // Get instance Basket basket = (Basket) 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 extends BaseBasket 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()); } } diff --git a/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java b/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java index 89c1db75..35b68a9f 100644 --- a/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java +++ b/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java @@ -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 diff --git a/src/java/org/mxchange/pizzaapplication/category/Category.java b/src/java/org/mxchange/pizzaapplication/category/Category.java index 16b38a64..a4cfc318 100644 --- a/src/java/org/mxchange/pizzaapplication/category/Category.java +++ b/src/java/org/mxchange/pizzaapplication/category/Category.java @@ -30,13 +30,13 @@ public interface Category extends Storeable, Comparable { * 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 index 00000000..58a6dd59 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java @@ -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 . + */ +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 () { + } +} diff --git a/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java index cab19857..4fde31e2 100644 --- a/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java +++ b/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java @@ -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" diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java index 60aa6751..e261e63d 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java @@ -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 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 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 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 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> iterator = map.entrySet().iterator(); + + // Init object instance + Storeable instance = new BasketItem(); + + // Iterate over all + while (iterator.hasNext()) { + // Get next entry + Map.Entry 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 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 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 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 result = this.getBackend().doSelectByCriteria(criteria); + + // Trace message + this.getLogger().debug(MessageFormat.format("result={0} - EXIT!", result)); //NOI18N + + // Return it + return result; } } diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java index 5a472e2a..323fae0a 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java @@ -16,7 +16,12 @@ */ 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; } diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java index 29aa737c..f6d8b380 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java @@ -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 diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java index 6f98dd40..32602a8d 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java @@ -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 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 diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java index 8ac757b2..55729e7f 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java @@ -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); diff --git a/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java index 97848c1d..d10a80e4 100644 --- a/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java +++ b/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java @@ -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" diff --git a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java index 06530318..7b20ca2f 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java @@ -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 diff --git a/src/java/org/mxchange/pizzaapplication/item/AddableBasketItem.java b/src/java/org/mxchange/pizzaapplication/item/AddableBasketItem.java index 4c0acd38..12e3346b 100644 --- a/src/java/org/mxchange/pizzaapplication/item/AddableBasketItem.java +++ b/src/java/org/mxchange/pizzaapplication/item/AddableBasketItem.java @@ -16,14 +16,14 @@ */ 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 { /** * 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); } diff --git a/src/java/org/mxchange/pizzaapplication/item/BaseItem.java b/src/java/org/mxchange/pizzaapplication/item/BaseItem.java index 33b6f131..7670ce41 100644 --- a/src/java/org/mxchange/pizzaapplication/item/BaseItem.java +++ b/src/java/org/mxchange/pizzaapplication/item/BaseItem.java @@ -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 } } diff --git a/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java b/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java index 40431736..0cc17af0 100644 --- a/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java +++ b/src/java/org/mxchange/pizzaapplication/item/basket/BasketItem.java @@ -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 } } diff --git a/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java b/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java index 744efd9a..153dfd8a 100644 --- a/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java +++ b/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java @@ -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; } /** diff --git a/src/java/org/mxchange/pizzaapplication/product/Product.java b/src/java/org/mxchange/pizzaapplication/product/Product.java index 2ff49328..c212df21 100644 --- a/src/java/org/mxchange/pizzaapplication/product/Product.java +++ b/src/java/org/mxchange/pizzaapplication/product/Product.java @@ -29,13 +29,13 @@ public interface Product extends Storeable, Comparable { * * @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. diff --git a/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java b/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java index ebc40b6e..82c43fa9 100644 --- a/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java +++ b/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java @@ -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); diff --git a/web/admin/category.jsp b/web/admin/category.jsp index c34277d3..e8769598 100644 --- a/web/admin/category.jsp +++ b/web/admin/category.jsp @@ -61,7 +61,7 @@ - + ${category.decodedTitle()} diff --git a/web/admin/product.jsp b/web/admin/product.jsp index e3515583..85006fcb 100644 --- a/web/admin/product.jsp +++ b/web/admin/product.jsp @@ -69,8 +69,8 @@ - ${product.getId()}: - + ${product.getItemId()}: + ${product.getTitle()} diff --git a/web/index.jsp b/web/index.jsp index e6b2b617..e9013807 100644 --- a/web/index.jsp +++ b/web/index.jsp @@ -112,7 +112,7 @@ - + diff --git a/web/index.xhtml b/web/index.xhtml index bf2e0c5a..ae4a587f 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -71,7 +71,7 @@ - + diff --git a/web/static/admin/admin_category_selection_box.jsp b/web/static/admin/admin_category_selection_box.jsp index 9eac81d6..39cbeab1 100644 --- a/web/static/admin/admin_category_selection_box.jsp +++ b/web/static/admin/admin_category_selection_box.jsp @@ -16,6 +16,6 @@ diff --git a/web/static/admin/admin_parent_category_selection_box.jsp b/web/static/admin/admin_parent_category_selection_box.jsp index d0412637..2004c883 100644 --- a/web/static/admin/admin_parent_category_selection_box.jsp +++ b/web/static/admin/admin_parent_category_selection_box.jsp @@ -17,6 +17,6 @@