From 10fe5fdbdb46d7a2cb830cf503a77a354a894193 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 26 Aug 2015 15:33:52 +0200 Subject: [PATCH] =?utf8?q?Renamed=20more=20stuff=20for=20fixes=20+=20updat?= =?utf8?q?ed=20jcore=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcore.jar | Bin 113187 -> 116351 bytes .../application/PizzaApplication.java | 4 +-- .../application/PizzaServiceApplication.java | 32 +++++++++--------- .../pizzaapplication/basket/BaseBasket.java | 2 ++ .../basket/BasketDatabaseConstants.java | 2 +- .../basket/BasketDatabaseFrontend.java | 6 +++- .../servlet/basket/BasketItemAddedFilter.java | 17 +++++++--- .../pizzaapplication/item/BaseItem.java | 2 +- web/index.jsp | 6 ++++ 9 files changed, 46 insertions(+), 25 deletions(-) diff --git a/lib/jcore.jar b/lib/jcore.jar index 03f8053610357bd974371cda9b66d6e5dddfcd39..f4bdc108ad5046a41cac1bfec183ec3cace35b8f 100644 GIT binary patch delta 7282 zcmZ`;33yahmOl4YrQS=`OGqmFN`=jAWFhQ$?H4M^tOLQoOf%ml%P6va&Z`>weuMg~?0!d#FbSi6Tn0Jdge;13Zn!Q^{$Mhva$ zo+N3$T(*B-*MKhoU5mKA`z|MCPfl$`VO=FHXobD8e3PR-rM$-8(D44x=Psbq4A^Rh zP*`Y&5Xe$skqp^p$brQc$c4KtkOxaFkPiiPTPnkH1qv-_$O^jMLo)YTU>Ow2uu_Iq z3anOOjTr*rJ{j(p;Q@mTYk7Lf5)s+LLeNivp?5SWlXrKg`C7{Bs~R2kRd)VuTV%il z_mggP15XYM_xJN6YVQ5&ayY+!I(m|iqqebr7Xw9WS34RROen0jZ?~s5HCEN6B7raK zoyK3e5YyI`!7qj>K3SOzGCAwYG%zR>+k#k#=nZ7^*lccpH<={(Prbpx#kgn&zN@P$ zYwe9q^$rG4#CwG2@WP(_+|b)S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lEtM zN%BUTC>ws?(rxr1S$p7p*(V0_Oh6o&$@T zQn4jjyN4RBc&<0-TDYig9iW;Beo$jh(nyA-)}Ew7X**6*uC!l^ob>}+s6g6+^OU5v zv{)x7b*_cvJfrTl&?IRmo+3HzsK!%FMBL79W8?2n(J*FVOfPGGrzDq2ay(Q>pm@p#!n52|BkpMtMUR0i!3kg>80*S z$j|-y%_S6`6{-)7nidi@RTZ73d?~S1i5AFfvK#DM|FxpdwoR7*I$g?TCZR7-vnShcn60X`cu6 zv1(t>kxJ7oM>%H(hw!iBQDrI2a;M|rfHI4;x4PAa+H~Fz-AeRXw>&=cL9s)Rrr?$R z;MY_?z$p;qu&N%rKrvF)(HA(yvPw&SJ2FOXW_hwii7x)`PbIu?xiY)WxoxU% zQLB9Z#dXrhm=;!$Z;*P~E&Qnv{{gs#_vgOq*EI}WIOO;p zj3J2kzOCLpO#|dOuA0R>^w9lq2Ui{OoBPk;4mGxu3@byk<9Ym=D=1f9NQRQ*ewQCx zd*u&VSmW_}A6_{jNA3{c>SpmB#7FR0E0v6PX(x9w=3=+Pq3Rsu$1Wvk7wz6lJa7Zm zy-rHE`jhoP-*0z^0dkEDN$}iFRdmVEWIHag=SLq~o=h-#5{)ji%=^EVY@Lf9RlP3x zE4@(^olX_q#Vc>6i=0d|4wVy2iE71V|FGT_lVN#&6JZpU`#uejsO9go<`*M^n!c*( z{lGv4_vpM&F9<=JINEQ|+>@p@U*WRLNImuEb6;-dX(-p|5c}^+gZAO-b_ElQI7#}~ zuWrmZ$?@6`hd(~a zpycZL;c2Shwk&8LVYdD 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 ... -- 2.39.5