From 8b74c6243b2f46a35037f9e5a6881a0dc8e4844e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 27 Aug 2015 23:52:56 +0200 Subject: [PATCH] =?utf8?q?Continued=20with=20project:=20-=20added=20method?= =?utf8?q?=20getProduct()=20-=20added=20method=20getLast()=20-=20added=20m?= =?utf8?q?ethod=20getAll()=20(again=3F)=20-=20Used=20BasketBean=20instead?= =?utf8?q?=20of=20Basket=20-=20Yepp,=20JSPs=20don't=20support=20@Inject=20?= =?utf8?q?and=20@PostConstruct=20...=20:-(=20-=20added=20getLastNumRows()?= =?utf8?q?=20which=20deligates=20this=20call=20to=20jcore's=20method=20-?= =?utf8?q?=20implemented=20MiniBasketTag=20(a=20bit=20broken)=20-=20added?= =?utf8?q?=20missing=20language=20resourced=20-=20updated=20jcore.jar=20Si?= =?utf8?q?gned-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 117379 -> 119585 bytes .../localization/bundle_de_DE.properties | 3 + .../localization/bundle_en_US.properties | 3 + .../application/PizzaApplication.java | 9 ++ .../application/PizzaServiceApplication.java | 33 +++++ .../pizzaapplication/basket/BaseBasket.java | 29 ++++ .../pizzaapplication/basket/Basket.java | 36 +++++ .../pizzaapplication/beans/PizzaBean.java | 9 ++ .../beans/PizzaServiceBean.java | 11 +- .../beans/basket/BasketBean.java | 36 +++++ .../beans/basket/ItemBasketBean.java | 19 +++ .../basket/BasketDatabaseFrontend.java | 135 ++++++++++++++++++ .../frontend/basket/BasketFrontend.java | 29 ++++ .../product/PizzaProductDatabaseFrontend.java | 107 ++++++++++---- .../frontend/product/ProductFrontend.java | 16 +++ .../servlet/basket/BasketItemAddedFilter.java | 16 ++- .../tags/basket/MiniBasketTag.java | 60 +++++++- web/form_handler/add_item.jsp | 4 + 18 files changed, 520 insertions(+), 35 deletions(-) diff --git a/lib/jcore.jar b/lib/jcore.jar index 11b967e308d9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tB7PO(TvV6i_R{W?y?=Z+Mb88J1cu!p&29<^wT;=8{_0;(X|(By{^4@c@6X9 zHEQ=14D>SD*7s+Iq^O^#FuF($9Gc1-8>HEd{yog9dvT`fO~>K@@62WchBA18lFm&M zolTN%PyAlJ-mu|K7K?6r)vlT7>*qyEq7-S$3;>GV?;rCDxCV`*a1FZl@iD?=z0hZFn4D=#o=@+Maq4gHn-s0$1#0f3~8=1 zN|Du;IUOfa#8fGLsOoY11lr%0>$7PZrXtG11zXOLx(l3uUvdEp3iOv9FDTQ)(F+`SsGlyY8_>SVxX} zD{Vro+U2ZjzY;}7ze7*uXg1$^gAkgKC~YNNOgL-G@6+m#6jHrRlomzxla}906+By?%p+w!%6NsL6 z)|!c4GSR4#2B4L>os%2??+TGUwZc}fa7zqFrQuO*s6Ij0pEzrT^0j)W!x_q1DjedKna{6tt5TY@UaGv#OS@lfCWes%yuP$sgMU8dl*ccd*MkjRV1e(vo0Xpm32>Tce?uILN$HrhYMUa zqEcfLt3Kl|J=C4=BEvOyW3Xq-yU2Gn-W2>8s;C$h+u&8dy-Rc}H`jJ&sreT(weLMPYjd#igcp-X5R);>l42Y$&N&Hw-a diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 376c5587..35d75a9f 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -17,3 +17,6 @@ BaseContact.gender.male.text=Herr BaseContact.gender.female.text=Frau BaseContact.gender.company.text=Firma MiniBasketTag.basket_is_empty=Der Warenkorb ist leer. +MiniBasketTag.last_item=Zuletzt hinzugefügt: {0} +MiniBasketTag.additional_items=Es befinden sich noch {0} weitere Produkte im Warenkorb. +MiniBasketTag.to_basket=Zum Warenkorb diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index d61b69f4..07e8210f 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -17,3 +17,6 @@ BaseContact.gender.male.text=Mr. BaseContact.gender.female.text=Mrs. BaseContact.gender.company.text=Company MiniBasketTag.basket_is_empty=Der Warenkorb ist leer. +MiniBasketTag.last_item=Zuletzt hinzugefügt: {0} +MiniBasketTag.additional_items=Es befinden sich noch {0} weitere Produkte im Warenkorb. +MiniBasketTag.to_basket=Zum Warenkorb diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java index dcb6060f..8515db3f 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java @@ -30,6 +30,7 @@ import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; import org.mxchange.pizzaapplication.category.Category; import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException; import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException; +import org.mxchange.pizzaapplication.item.AddableBasketItem; import org.mxchange.pizzaapplication.product.Product; /** @@ -341,4 +342,12 @@ public interface PizzaApplication extends Application { * @throws ServletException If something unexpected happened */ public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException; + + /** + * Some "getter" for a Product instance from given item + * @param item Item instance + * @return A Product instance + * @throws ServletException If something unexpected happened + */ + public Product getProduct (final AddableBasketItem item) throws ServletException; } diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index b7f057c0..ff05279f 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -38,6 +38,7 @@ import org.mxchange.pizzaapplication.database.frontend.product.PizzaProductDatab import org.mxchange.pizzaapplication.database.frontend.product.ProductFrontend; import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException; import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException; +import org.mxchange.pizzaapplication.item.AddableBasketItem; import org.mxchange.pizzaapplication.product.Product; /** @@ -1577,4 +1578,36 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Return it return isUsed; } + + @Override + public Product getProduct (final AddableBasketItem item) throws ServletException { + // Trace message + this.getLogger().trace("item=" + item + " - CALLED!"); + + // item should not be null + if (null == item) { + // Abort here + throw new NullPointerException("item is null"); + } else if (null == this.productFrontend) { + // Abort here + throw new NullPointerException("productFrontend is null"); + } + + // Init product instance + Product product = null; + + try { + // Call frontend + product = this.productFrontend.getProduct(item); + } catch (final SQLException | IOException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + // Continue to throw + throw new ServletException(ex); + } + + // Trace message + this.getLogger().trace("product=" + product + " - EXIT!"); + + // Return it + return product; + } } diff --git a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java index 3645d04c..58ff9cf6 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java @@ -21,6 +21,7 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.text.MessageFormat; +import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import org.mxchange.jcore.exceptions.BadTokenException; @@ -163,4 +164,32 @@ public class BaseBasket extends BasePizzaServiceSys // Return it return isAdded; } + + @Override + public Map getAll () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Trace message + this.getLogger().trace("CALLED!"); + + // Init map + @SuppressWarnings("unchecked") + Map map = (Map) ((BasketFrontend) this.getFrontend()).getAll(); + + // Trace message + this.getLogger().trace("map=" + map); + + // Return it + return map; + } + + @Override + public AddableBasketItem getLast () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Deligate to frontend + return ((BasketFrontend) this.getFrontend()).getLast(); + } + + @Override + public int getLastNumRows () { + // Deligate to frontend + return this.getFrontend().getLastNumRows(); + } } diff --git a/src/java/org/mxchange/pizzaapplication/basket/Basket.java b/src/java/org/mxchange/pizzaapplication/basket/Basket.java index b583b530..462d4668 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/Basket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/Basket.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; +import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; import org.mxchange.jcore.FrameworkInterface; @@ -107,4 +108,39 @@ public interface Basket extends Serializable, Frame * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found */ public void init (final ServletContext context, final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException; + + /** + * Some "getter" for all entries in this basket + * + * @return Map on all basket items + * @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 Map getAll () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Getter for last entry + * + * @return Last added item in 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 AddableBasketItem getLast () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Getter for last num rows + * + * @return Last num rows + */ + public int getLastNumRows (); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java b/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java index 539b0e7b..84a35600 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java @@ -29,6 +29,7 @@ import org.mxchange.pizzaapplication.beans.basket.BasketBean; import org.mxchange.pizzaapplication.category.Category; import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException; import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException; +import org.mxchange.pizzaapplication.item.AddableBasketItem; import org.mxchange.pizzaapplication.product.Product; /** @@ -334,4 +335,12 @@ public interface PizzaBean extends Serializable { * @param application the application to set */ public void setApplication (final ServletContext application); + + /** + * Some "getter" for a product from given item + * @param item Item instance + * @return A Product instance + * @throws javax.servlet.ServletException If something bad happens + */ + public Product getProduct (final AddableBasketItem item) throws ServletException; } diff --git a/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java b/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java index fbbb338f..d234d668 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java @@ -39,6 +39,7 @@ import org.mxchange.pizzaapplication.beans.basket.BasketBean; import org.mxchange.pizzaapplication.category.Category; import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException; import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException; +import org.mxchange.pizzaapplication.item.AddableBasketItem; import org.mxchange.pizzaapplication.product.Product; /** @@ -418,7 +419,7 @@ public class PizzaServiceBean implements PizzaBean { @Override public BasketBean getBasket () { // Trace message - this.getLogger().trace("basked=" + this.basket + " - EXIT!"); + this.getLogger().trace("basket=" + this.basket + " - EXIT!"); // Return it return this.basket; @@ -430,7 +431,7 @@ public class PizzaServiceBean implements PizzaBean { @Override public void setBasket (final BasketBean basket) { // Trace message - this.getLogger().trace("basked=" + basket + " - CALLED!"); + this.getLogger().trace("basket=" + basket + " - CALLED!"); // Set it here this.basket = basket; @@ -459,4 +460,10 @@ public class PizzaServiceBean implements PizzaBean { // Set it here this.application = application; } + + @Override + public Product getProduct (final AddableBasketItem item) throws ServletException { + // Deligate to application + return this.app.getProduct(item); + } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java index c37e6322..490740f7 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; +import java.util.Map; import javax.faces.FacesException; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; @@ -135,4 +136,39 @@ public interface BasketBean extends Serializable { * @param session the session to set */ public void setSession (final HttpSession session); + + /** + * Some "getter" for all entries in this basket + * + * @return Map on all basket items + * @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 Map getAll () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Getter for last entry + * + * @return Last added item in 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 AddableBasketItem getLast () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Getter for last num rows + * + * @return Last num rows + */ + public int getLastNumRows (); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java index 1a8f7663..ce19d151 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.basket; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; +import java.util.Map; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.FacesException; @@ -174,4 +175,22 @@ public class ItemBasketBean implements BasketBean { public void setSession (final HttpSession session) { this.session = session; } + + @Override + public Map getAll () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Deligate to basket instance + return this.basket.getAll(); + } + + @Override + public AddableBasketItem getLast () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Deligate to basket instance + return this.basket.getLast(); + } + + @Override + public int getLastNumRows () { + // Delegate to basket + return this.basket.getLastNumRows(); + } } 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 fb563d84..28d4033b 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketDatabaseFrontend.java @@ -21,7 +21,9 @@ import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.text.MessageFormat; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; import org.mxchange.jcore.criteria.logical.and.AndLogicalMatcher; import org.mxchange.jcore.criteria.searchable.SearchCriteria; import org.mxchange.jcore.criteria.searchable.SearchableCriteria; @@ -409,4 +411,137 @@ public class BasketDatabaseFrontend extends BaseDatabaseFrontend implements Bask // Return it return result; } + + @Override + public Map getAll () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Trace message + this.getLogger().trace("CALLED!"); + + // Session should be set here + if (this.getSessionId() == null) { + // Abort here + throw new NullPointerException("sessionId is null"); + } + + // Init seaerch instance + SearchableCriteria criteria = new SearchCriteria(); + + // Add only session id + criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, this.getSessionId()); + + // Now run it on backend + Result result = this.getBackend().doSelectByCriteria(criteria); + + // Now convert it to a map + Set set = result.resultSet(); + + // Debug message + this.getLogger().debug("set=" + set); + + // Init map + Map map = new LinkedHashMap<>(set.size()); + + // Add all entries + for (final Storeable storeable : set) { + // Debug message + this.getLogger().debug("storeable=" + storeable); + + // Check on AddableBasketItem + if (!(storeable instanceof AddableBasketItem)) { + // Not correct instance + throw new IllegalStateException("storeable=" + storeable + " does not implement AddableBasketItem."); + } + + // Get id + Long id = ((AddableBasketItem) storeable).getItemId(); + + // Debug message + this.getLogger().debug("id=" + id); + + // Add it + map.put(id, (AddableBasketItem) storeable); + } + + // Trace message + this.getLogger().trace("map=" + map + " - EXIT!"); + + // Return it + return map; + } + + @Override + public AddableBasketItem getLast () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Trace message + this.getLogger().trace("CALLED!"); + + // Session should be set here + if (this.getSessionId() == null) { + // Abort here + throw new NullPointerException("sessionId is null"); + } + + // Init seaerch instance + SearchableCriteria criteria = new SearchCriteria(); + + // Add only session id + criteria.addCriteria(BasketDatabaseConstants.COLUMN_SESSION_ID, this.getSessionId()); + + // Get number of rows + int rows = this.getBackend().numRows(criteria); + + // Debug message + this.getLogger().debug("rows=" + rows); + + // Nothing found? + if (rows == 0) { + // Debug message + this.getLogger().debug("Nothing found, returning null ... - EXIT!"); + + // Return null + return null; + } + + // Debug message + this.getLogger().debug("rows=" + rows); + + // Set last num rows + this.setLastNumRows(rows); + + // Now set this -1 as skip value and limit to 1 + criteria.setSkip(rows); + criteria.setLimit(1); + + // And run it ... + Result result = this.getBackend().doSelectByCriteria(criteria); + + // Debug message + this.getLogger().debug("result=" + result); + + // Init instance + AddableBasketItem item; + + // There should be something! + if (!result.hasNext()) { + // Something isn't working here ... + throw new IllegalStateException("result has zero entries, but rows=" + rows); + } + + // Get next element + Storeable storeable = result.next(); + + // Is it still castable? + if (!(storeable instanceof AddableBasketItem)) { + // Opps! + throw new IllegalStateException("storeable=" + storeable + " does not implement AddableBasketItem."); + } + + // Cast it + item = (AddableBasketItem) storeable; + + // Trace message + this.getLogger().trace("item=" + item + " - EXIT!"); + + // Return it + return item; + } } 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 45d53260..75391e81 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/basket/BasketFrontend.java @@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.database.frontend.basket; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; +import java.util.Map; import org.mxchange.jcore.database.frontend.DatabaseFrontend; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; @@ -87,4 +88,32 @@ public interface BasketFrontend extends DatabaseFrontend { * @throws java.lang.reflect.InvocationTargetException If anything else happened? */ public boolean isItemAdded (final AddableBasketItem item, final String sessionId) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Some "getter" for all entries in this basket + * + * @return Map on all basket items + * @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 Map getAll () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Getter for last entry + * + * @return Last added item in 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 AddableBasketItem getLast () throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; } 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 1c9008a9..768757dd 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java @@ -32,6 +32,7 @@ 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.item.AddableBasketItem; import org.mxchange.pizzaapplication.product.Product; import org.mxchange.pizzaapplication.product.pizza.PizzaProduct; @@ -44,7 +45,9 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement /** * Default constrcutor - * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the configured backend is not supported + * + * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException + * If the configured backend is not supported * @throws java.sql.SQLException If any SQL error occurs */ public PizzaProductDatabaseFrontend () throws UnsupportedDatabaseBackendException, SQLException { @@ -60,6 +63,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement /** * Adds product to database by given title, price and category id + * * @param title Product title * @param price Product price * @param category Product category id @@ -70,7 +74,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement public void addProduct (final String title, final Float price, final Long category, final Boolean available) throws SQLException, IOException { // Trace message this.getLogger().trace(MessageFormat.format("title={0},price={1},category={2} - CALLED!", title, price, category)); //NOI18N - + // Title should not be null if (null == title) { // Abort here @@ -85,30 +89,30 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement // Abort here throw new NullPointerException("available is null"); //NOI18N } - + // Clear dataset from previous usage this.clearDataSet(); - + // Add title and parent this.addToDataSet(ProductFrontend.COLUMN_TITLE, title); this.addToDataSet(ProductFrontend.COLUMN_PRICE, price); this.addToDataSet(ProductFrontend.COLUMN_CATEGORY, category); this.addToDataSet(ProductFrontend.COLUMN_AVAILABLE, available); - + // 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 } /** * Shuts down the database layer - * + * * @throws java.sql.SQLException If an SQL error occurs * @throws java.io.IOException If any IO error occurs */ @@ -158,11 +162,12 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement * * @return Iterator on all products * @throws java.io.IOException If any IO error occurs - * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found in a file-based database backend's file ... ;-) + * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token + * was found in a file-based database backend's file ... ;-) * @throws java.sql.SQLException If any SQL errors occur */ @Override - @SuppressWarnings ("unchecked") + @SuppressWarnings("unchecked") public Iterator getAllProducts () throws IOException, BadTokenException, SQLException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace("CALLED!"); //NOI18N @@ -187,7 +192,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement } @Override - @SuppressWarnings ("unchecked") + @SuppressWarnings("unchecked") public Iterator getAvailableProducts () throws IOException, BadTokenException, SQLException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace("CALLED!"); //NOI18N @@ -197,7 +202,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement // Add criteria criteria.addCriteria(ProductFrontend.COLUMN_AVAILABLE, true); - + // Run the query Result result = this.getBackend().doSelectByCriteria(criteria); @@ -278,43 +283,46 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement * @param title Product title * @return Whether the product title is already used * @throws java.io.IOException If any IO error occurs - * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found in a file-based database backend's file ... ;-) + * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token + * was found in a file-based database backend's file ... ;-) * @throws java.sql.SQLException If any SQL errors occur */ @Override public boolean isProductTitleUsed (String title) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message this.getLogger().trace(MessageFormat.format("title={0} - CALLED!", title)); //NOI18N - + // Get search criteria SearchableCriteria criteria = new SearchCriteria(); - + // Add criteria criteria.addCriteria(ProductFrontend.COLUMN_TITLE, title); - + // 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 - + // Now check size of the result boolean isFound = (result.size() == 1); - + // Trace message this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound)); //NOI18N - + // Return it return isFound; } /** - * 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 @@ -360,4 +368,55 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement // Return it return instance; } + + @Override + public Product getProduct (final AddableBasketItem item) throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + // Trace message + this.getLogger().trace("item=" + item + " - CALLED!"); + + // item should not be null + if (null == item) { + // Abort here + throw new NullPointerException("item is null"); + } + + // Get search criteria + SearchableCriteria criteria = new SearchCriteria(); + + // Add criteria + criteria.addCriteria(ProductFrontend.COLUMN_ITEM_ID, item.getItemId()); + + // 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 product instance + Product product = null; + + // Is there one entry? + if (result.hasNext()) { + // Get item + Storeable storeable = result.next(); + + // Is it Product? + if (!(storeable instanceof Product)) { + // Cannot cast! + throw new IllegalStateException("storeable=" + storeable + " does not implement Product."); + } + + // Cast it + product = (Product) storeable; + } + + // Trace message + this.getLogger().trace("product=" + product + " - EXIT!"); + + // Return it + return product; + } } diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/product/ProductFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/product/ProductFrontend.java index 6cc26149..6e71d77c 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/ProductFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/ProductFrontend.java @@ -23,6 +23,7 @@ import java.util.Iterator; 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; /** @@ -105,4 +106,19 @@ public interface ProductFrontend extends DatabaseFrontend { * @throws java.lang.reflect.InvocationTargetException Any other problems? */ public boolean isProductTitleUsed (String title) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; + + /** + * Some "getter" for a Product instance from given item + * + * @param item Item instance + * @return A Product instance + * @throws java.io.IOException If any IO error occurs + * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found in a file-based database backend's file ... ;-) + * @throws java.sql.SQLException If any SQL errors occur + * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If the database file is damaged + * @throws java.lang.NoSuchMethodException If a method was not found + * @throws java.lang.IllegalAccessException If the method cannot be accessed + * @throws java.lang.reflect.InvocationTargetException Any other problems? + */ + public Product getProduct (final AddableBasketItem item) throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; } 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 46ff6fa2..367a904b 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/servlet/basket/BasketItemAddedFilter.java @@ -29,7 +29,8 @@ 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.pizzaapplication.basket.Basket; +import org.mxchange.pizzaapplication.beans.PizzaBean; +import org.mxchange.pizzaapplication.beans.basket.BasketBean; import org.mxchange.pizzaapplication.filter.servlet.BaseServletFilter; import org.mxchange.pizzaapplication.item.AddableBasketItem; @@ -83,7 +84,7 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { 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())); //NOI18N // Init instance - Basket basket; + BasketBean basket; try { // Get session instance HttpSession session = ((HttpServletRequest) request).getSession(); @@ -97,8 +98,17 @@ public class BasketItemAddedFilter extends BaseServletFilter implements Filter { throw new NullPointerException("session is null"); //NOI18N } + // Get man controller + PizzaBean bean = (PizzaBean) session.getAttribute("controller"); //NOI18N + + // Debug message + this.getLogger().debug("bean=" + bean); + // Get basket instance - basket = (Basket) session.getAttribute("basket"); //NOI18N + basket = bean.getBasket(); + + // Debug message + this.getLogger().debug("basket=" + basket); // Is the item already added? if (item.getItemId() == null) { diff --git a/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java b/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java index b0d84b9e..a2b9440b 100644 --- a/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java +++ b/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java @@ -19,13 +19,18 @@ package org.mxchange.pizzaapplication.tags.basket; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; +import java.text.MessageFormat; +import javax.servlet.ServletException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyTagSupport; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; +import org.mxchange.pizzaapplication.beans.PizzaBean; import org.mxchange.pizzaapplication.beans.basket.BasketBean; +import org.mxchange.pizzaapplication.item.AddableBasketItem; +import org.mxchange.pizzaapplication.product.Product; /** * A basket tag that outputs a small basket and a link to the full basket website. @@ -80,14 +85,57 @@ public class MiniBasketTag extends BodyTagSupport implements BasketTag { // Some entries found? if (this.getBasket().isEmpty()) { // Empty basket - out.append("
\n"); + out.append("
\n"); out.append(this.getBasket().getMessageStringFromKey("MiniBasketTag.basket_is_empty")).append("\n"); out.append("
\n"); } else { - // Some times were found - out.append("FOUND!"); + // Get all items + AddableBasketItem item = this.getBasket().getLast(); + + // item cannot be null here + if (null == item) { + // Abort here + throw new NullPointerException("item is null"); + } + + // Get application bean from session + PizzaBean bean = (PizzaBean) this.getBasket().getSession().getAttribute("controller"); + + // Debug log + this.LOG.debug("bean=" + bean); + + // Should not be null + if (null == bean) { + // Abort here + throw new NullPointerException("bean is null"); + } + + // Get product instance + Product product = bean.getProduct(item); + + // Debug message + this.LOG.debug("product=" + product); + + // Get last num rows + int lastNumRows = this.getBasket().getLastNumRows(); + + // Debug message + this.LOG.debug("lastNumRows=" + lastNumRows); + + // Output all + out.append("
\n"); + out.append("
\n"); + out.append(" ").append(MessageFormat.format(this.getBasket().getMessageStringFromKey("MiniBasketTag.last_item"), product.getTitle())); + out.append("
\n"); + out.append("
\n"); + out.append(" ").append(MessageFormat.format(this.getBasket().getMessageStringFromKey("MiniBasketTag.additional_items"), (lastNumRows - 1))); + out.append("
\n"); + out.append(" \n"); + out.append("
\n"); } - } catch (final IOException | SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { + } catch (final ServletException | IOException | SQLException | BadTokenException | CorruptedDatabaseFileException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { // Continue to throw throw new JspException(ex); } @@ -116,7 +164,7 @@ public class MiniBasketTag extends BodyTagSupport implements BasketTag { @Override public BasketBean getBasket () { // Trace message - this.LOG.trace("basket=" + this.basket + " - EXIT!"); + //* NOISY-DEBUG: */ this.LOG.trace("basket=" + this.basket + " - EXIT!"); // Return it return this.basket; @@ -128,7 +176,7 @@ public class MiniBasketTag extends BodyTagSupport implements BasketTag { @Override public void setBasket (final BasketBean basket) { // Trace message - this.LOG.trace("basked=" + basket + " - CALLED!"); + //* NOISY-DEBUG: */ this.LOG.trace("basked=" + basket + " - CALLED!"); // Set it here this.basket = basket; diff --git a/web/form_handler/add_item.jsp b/web/form_handler/add_item.jsp index aa07ebf6..d5638079 100644 --- a/web/form_handler/add_item.jsp +++ b/web/form_handler/add_item.jsp @@ -13,6 +13,10 @@ + + +<%controller.init();%> + -- 2.39.5