From aab62521c277a8269a690e2b8b2efcae8dd1730f Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 26 Aug 2015 14:39:32 +0200 Subject: [PATCH] =?utf8?q?Continued=20with=20project:=20-=20Had=20to=20ren?= =?utf8?q?amed=20id=20->=20itemId=20and=20categoryId=20accordingly=20to=20?= =?utf8?q?allow=20databased-=20baskets=20-=20Implemented=20almost=20all=20?= =?utf8?q?methods=20in=20basket=20database=20frontend=20class=20-=20Added?= =?utf8?q?=20constants=20class=20for=20above=20frontend=20-=20Updated=20jc?= =?utf8?q?ore=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 113081 -> 113187 bytes .../application/PizzaApplication.java | 4 +- .../application/PizzaServiceApplication.java | 100 +++---- .../pizzaapplication/basket/BaseBasket.java | 75 ++++- .../pizzaapplication/basket/Basket.java | 32 ++- .../basket/item/ItemBasket.java | 30 +- .../category/BaseCategory.java | 38 +-- .../pizzaapplication/category/Category.java | 4 +- .../basket/BasketDatabaseConstants.java | 55 ++++ .../PizzaCategoryDatabaseConstants.java | 2 +- .../basket/BasketDatabaseFrontend.java | 262 +++++++++++++++++- .../frontend/basket/BasketFrontend.java | 30 +- .../frontend/category/CategoryFrontend.java | 3 +- .../PizzaCategoryDatabaseFrontend.java | 48 ++-- .../product/PizzaProductDatabaseFrontend.java | 4 +- .../PizzaProductDatabaseConstants.java | 4 +- .../servlet/basket/BasketItemAddedFilter.java | 35 +-- .../item/AddableBasketItem.java | 40 ++- .../pizzaapplication/item/BaseItem.java | 116 +++++++- .../item/basket/BasketItem.java | 6 +- .../pizzaapplication/product/BaseProduct.java | 22 +- .../pizzaapplication/product/Product.java | 4 +- .../product/pizza/PizzaProduct.java | 2 +- web/admin/category.jsp | 2 +- web/admin/product.jsp | 4 +- web/index.jsp | 2 +- web/index.xhtml | 2 +- .../admin/admin_category_selection_box.jsp | 2 +- .../admin_parent_category_selection_box.jsp | 2 +- 29 files changed, 748 insertions(+), 182 deletions(-) create mode 100644 src/java/org/mxchange/pizzaapplication/database/basket/BasketDatabaseConstants.java diff --git a/lib/jcore.jar b/lib/jcore.jar index b40acb8717dea690b57943fc2d49e304bed8278f..03f8053610357bd974371cda9b66d6e5dddfcd39 100644 GIT binary patch delta 12939 zcmaJo33wDm*6&sKOm`+7NQN9t0wh2}LQWDOK!9*x1_*~7Q8@wx2w=h$1UUv&P(YB_ z$jBjQAlw832@ye56m``Vbv;*I|J8LpQ1@R~R{{CotL_<+i2r=)?&_*n@4b5UuBz(P z{oA?kM`y^0JVkW@=m0ksM3;vo>DL!T5BlaGZ;SGt#f~m%Q#xdpA6cqUrP&^1&PM$mcg|Z~07jWU#9TQ1`7Ih(YGvPK%+L&OtU*yl>?})Xh)qh7iT7@QpZ&jpfim z>lH@Q8U*!z9`m`1NZ${Sqto1>S-1~rITAOcqK0s@mF^1TsVMwpuBwa#;478;nfZDf z@2f5_aJvh4;8Q{H2JUpxZ5Nkz^KB2`_Hx}m7i`7~F74OxfQFSWJcx&a@h~1?3`bqi z9FMu60FUcQLz*6HYd+667}oQ}`vc%H#7xbRuL z$S}|G?Rmbvpy4GQUv$AFe8~mv@G|3lS;tqn@l_rFq~mKYcoSdO@eLjStmB(HUeWO_ z9pBdR9UcFoc=4|~e$0G-qT#1H{>=q_@iPtoho66U z!2tZ6OJDHq9}M;-*KOz0Kl%0*zkbc7Z@BcWj#qX3PRH+c{6WWm>G;1o{@aB=;(s*! zNyndc{I3gt!C!f(*IW?e#p@d0(D64O+)b(#z&F%|(1oH4RTmCjICY`Xn1xP+M363A zx(L>Vp^FfgXd;^OEz~8#gqv^82$cxeM1(FPT~J0N6;Zlqt_u&dd58urqID6Yix#?Q z>7^+Vt#lEqi8vQLfS>E4wM(=SZFLdP#1eGTP8W&6B1yE@MRKr6At{SgdWtl@r3Z@) z(ShbcWb!SGZyhz!NfVuQk?n#fn0yz~9nqD?)lC;U%s?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64dN5LB_Fj zs6}${#5rM~Y$s6ud%z7#WkuPYF&w;)fEr%;RK-mC1i*g@_dxx9oKbdwuH(#}VAsDH zZ!=CGM@@|A(s7dYnMr2v%F#CC*W>6A#Lj%uDsBob1pZ6ChuGJXIe4To>;#4jBC}2q zkpm^XHB|p_mSP-r_q@h?mT&O%=+A~JhW#XpWo<;9q~15Sx_kY3j%zYsGG4i{h0ay@ zFXbNQukSI+PolVTY+UE~hbwqPJHzi3wh@9Kv(1HfNKgFN`5xS*l>$^>c_hSGbjnh# zCtaqLnP(pEzlyTwj+&IOA4ESR(1AANE#e_Y{Ou{?e5C%~eupvev^BCZr>Q^bqA|Pz zV~u^Mv4c5_|NU{jAALdKKkm-me>96%1gO6C)fR^9j7221iinK8X7)6`86kQEp>6x~ zuiOeEM@7G(ZYoq(l==Q(f)BYH(*(Y@-{Fi_aRB_+?;h~ss&VEFw$ra)RE^$rudxZI zUE-FP`jPhekLPsmzlySJoj6WT1h>m>Pj))>GwGTCvfLn4R+No1g3ekCam-m7M^zTb ziqIo}QjIa)iBrQ_%LK3S?hSeF?$$=TYRd{<`r7IImDUXZ@l4YFS5a1yZ_1s0RWU9< zgaO8CH;%{M|ITb19(CjR^AO+=19+=0?Ye_N`S0FgK4Ju&v)0u;altJFl@()@#m?(!xXc>aSC>B>e|h_{7TF&cMLJT zsc#K+g-`c%wKKk+fkDQ!8VnK^xq|nn%=Gm47KZX8tepHMg$Mr2zDM%FIVLDwz7Nv( z+EgQTKB+OU)*8h4S|T@ksR={(@LL*(++7!VSM+iVeJwhS>&x-?9Ll}TKTW{ zJ*>-Cn7DMCKh~IDXK`Fv$H}hobOjq#D>1})&)xqm@1MHXBav!U?H~uATW{fyuBZOn mPg?zS_g}<8W4F7%iuYgM=IIYMX6o3=@V|h8w#0p8zwkfRmJHnh 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 @@ -- 2.39.5