From: Roland Haeder Date: Wed, 26 Aug 2015 13:33:52 +0000 (+0200) Subject: Renamed more stuff for fixes + updated jcore X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=10fe5fdbdb46d7a2cb830cf503a77a354a894193;p=pizzaservice-war.git Renamed more stuff for fixes + updated jcore Signed-off-by:Roland Häder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index 03f80536..f4bdc108 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 37829105..88886d5d 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java @@ -45,12 +45,12 @@ public interface PizzaApplication extends Application { /** * HTTP parameter "item_id" */ - public static final String HTTP_PARAM_ITEM_ID = "item_id"; //NOI18N + public static final String HTTP_PARAM_ITEM_ID = "itemId"; //NOI18N /** * HTTP parameter "type" */ - public static final String HTTP_PARAM_ITEM_TYPE = "type"; //NOI18N + public static final String HTTP_PARAM_ITEM_TYPE = "itemType"; //NOI18N /** * Session key "ordered" diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index 459d6c7d..51e3d377 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -167,7 +167,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -219,7 +219,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -282,7 +282,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -326,7 +326,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } else if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -363,7 +363,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -401,7 +401,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -448,7 +448,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } else if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -525,7 +525,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("session={0},key={1} - CALLED", session, key)); //NOI18N // Are both parameter not null? - if (session == null) { + if (null == session) { // Abort here throw new NullPointerException("session is null"); //NOI18N } else if (key == null) { @@ -612,7 +612,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } else if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -688,7 +688,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } else if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -755,7 +755,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } else if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -835,7 +835,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -863,7 +863,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -912,7 +912,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -940,7 +940,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P if (null == product) { // Not set throw new NullPointerException("product is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } @@ -1041,7 +1041,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } else if (request == null) { // Not set throw new NullPointerException("request is null"); //NOI18N - } else if (session == null) { + } else if (null == session) { // Not set throw new NullPointerException("session is null"); //NOI18N } diff --git a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java index 79633d7b..819b853d 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java @@ -170,6 +170,8 @@ public class BaseBasket extends BaseFrameworkSystem this.getLogger().trace(MessageFormat.format("in={0} - CALLED!", in)); try { + // Init everything else + // Init frontend BasketFrontend frontend = new BasketDatabaseFrontend(); diff --git a/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java index 58a6dd59..91ede812 100644 --- a/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java +++ b/src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java @@ -40,7 +40,7 @@ public final class BasketDatabaseConstants { /** * Column for product type */ - public static final String COLUMN_PRODUCT_TYPE = "item_type"; //NOI18N + public static final String COLUMN_ITEM_TYPE = "item_type"; //NOI18N /** * Column for session id or any unique identifier 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 e261e63d..b6097c9b 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java @@ -22,6 +22,7 @@ import java.sql.SQLException; import java.text.MessageFormat; import java.util.Iterator; import java.util.Map; +import org.mxchange.jcore.criteria.logical.and.AndLogicalMatcher; import org.mxchange.jcore.criteria.searchable.SearchCriteria; import org.mxchange.jcore.criteria.searchable.SearchableCriteria; import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend; @@ -82,7 +83,7 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask 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()); + this.addToDataSet(BasketDatabaseConstants.COLUMN_ITEM_TYPE, item.getItemType()); // Handle this over to the backend // @todo Nothing is done yet! @@ -305,6 +306,9 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, sessionId); criteria.setLimit(1); + // Set AND logical matcher + criteria.setLogical(new AndLogicalMatcher()); + // Now search for it Result result = this.getBackend().doSelectByCriteria(criteria); 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 7b20ca2f..13b96c95 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java @@ -80,6 +80,9 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { // Now it is secure to cast AddableBasketItem item = (AddableBasketItem) object; + // Debug message + this.getLogger().debug(MessageFormat.format("item.id={0},item.itemId={1},item.itemType={2},item.amount={3}", item.getId(), item.getItemId(), item.getItemType(), item.getAmount())); + // Init instance Basket basket; try { @@ -90,7 +93,7 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { this.getLogger().debug(MessageFormat.format("session={0}", session)); //NOI18N // Should not be null - if (session == null) { + if (null == session) { // session is null throw new NullPointerException("session is null"); //NOI18N } @@ -99,15 +102,21 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { basket = ItemBasket.getInstance(session); // Is the item already added? - if ((item.getAmount() == null) || (item.getAmount() == 0)) { + if (item.getItemId() == null) { + // Item id is not set + throw new NullPointerException(MessageFormat.format("item id of item={0} is null", item)); //NOI18N + } else if (item.getItemType() == null) { + // Item type is not set + throw new NullPointerException(MessageFormat.format("item type of item={0} is null", item)); //NOI18N + } else if ((item.getAmount() == null) || (item.getAmount() == 0)) { // Debug message - this.getLogger().debug("Amount for item " + item + " is null"); + this.getLogger().debug(MessageFormat.format("Amount for item {0} is null", item)); //NOI18N // 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())); + throw new ServletException(MessageFormat.format("item id={0} has already been added.", item.getItemId())); //NOI18N } // Register item with it diff --git a/src/java/org/mxchange/pizzaapplication/item/BaseItem.java b/src/java/org/mxchange/pizzaapplication/item/BaseItem.java index 7670ce41..43df54f8 100644 --- a/src/java/org/mxchange/pizzaapplication/item/BaseItem.java +++ b/src/java/org/mxchange/pizzaapplication/item/BaseItem.java @@ -62,7 +62,7 @@ public class BaseItem extends BaseFrameworkSystem implements AddableBasketItem { } // Debug message - this.getLogger().debug(MessageFormat.format("this.id={0},item.id={1}", this.getItemId(), item.getItemId())); //NOI18N + this.getLogger().debug(MessageFormat.format("this.itemId={0},item.itemId={1}", this.getItemId(), item.getItemId())); //NOI18N // Is the id the same? if (Objects.equals(this.getItemId(), item.getItemId())) { diff --git a/web/index.jsp b/web/index.jsp index e9013807..a0757c00 100644 --- a/web/index.jsp +++ b/web/index.jsp @@ -70,12 +70,18 @@ // Get product instance Product product = iterator.next(); + // Debug message + product.getLogger().debug("product.itemId=" + product.getItemId()); + // Get basket instance Basket basket = ItemBasket.getInstance(session); // Create an item instance form this product AddableBasketItem item = basket.getItem(product); + // Debug message + product.getLogger().debug("item=" + item); + // Has it been already added to the basket? if (item != null) { // Some nice output ...