From: Roland Haeder Date: Thu, 27 Aug 2015 19:05:37 +0000 (+0200) Subject: Continued with project: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=121b8ad3c14b055d76ecfd71cab3878668d1a349;p=pizzaservice-war.git Continued with project: - started to refacture all JSPs towards JSFs - this requires a lot to be rewritten - moved some classes to better location - deleted some old JSPs - moved constants from FooBarConstants class to proper interface - removed above mentioned classes - added interface BasketTag - updated jcore.jar Signed-off-by:Roland Häder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index 68d45378..11b967e3 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties index 9d9683c2..5817b497 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -41,11 +41,11 @@ j2ee.compile.on.save=true j2ee.copy.static.files.on.save=true j2ee.deploy.on.save=true j2ee.platform=1.5 -j2ee.platform.classpath=${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar +j2ee.platform.classpath=${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.persistence.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar -j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar -j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar j2ee.platform.wsit.classpath= j2ee.server.type=gfv3ee6 jar.compress=false diff --git a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java index 8fe69815..17c7504c 100644 --- a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java +++ b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java @@ -34,6 +34,12 @@ public class BasePizzaServiceSystem extends BaseFrameworkSystem { // Trace message this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N + // context shall not be null + if (null == context) { + // Abort here + throw new NullPointerException("context is null"); + } + // We need some properties that needs to be set for (final String name : this.getPropertyNames()) { // Debug log diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java index 38d7dd4f..dcb6060f 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaApplication.java @@ -118,7 +118,9 @@ public interface PizzaApplication extends Application { * @param request Request instance * @param session Session instance * @return Amount as string + * @deprecated Old code */ + @Deprecated public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session); /** diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index fa19b61b..b7f057c0 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -32,12 +32,10 @@ import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; import org.mxchange.pizzaapplication.BasePizzaServiceSystem; import org.mxchange.pizzaapplication.category.Category; -import org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants; import org.mxchange.pizzaapplication.database.frontend.category.CategoryFrontend; import org.mxchange.pizzaapplication.database.frontend.category.PizzaCategoryDatabaseFrontend; import org.mxchange.pizzaapplication.database.frontend.product.PizzaProductDatabaseFrontend; import org.mxchange.pizzaapplication.database.frontend.product.ProductFrontend; -import org.mxchange.pizzaapplication.database.product.PizzaProductDatabaseConstants; import org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException; import org.mxchange.pizzaapplication.exceptions.ProductTitleAlreadyUsedException; import org.mxchange.pizzaapplication.product.Product; @@ -58,11 +56,25 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ private CategoryFrontend categoryFrontend; + /** + * Default constructor + */ + public PizzaServiceApplication () { + // Trace message + this.getLogger().trace("CALLED!"); + } + @Override public void init (final ServletContext context) throws UnsupportedDatabaseBackendException, SQLException { // Trace message this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N + // context should not be null + if (null == context) { + // Abort here + throw new NullPointerException("context is null"); + } + // Is the bundle initialized? if (!this.isBundledInitialized()) { // Temporary initialize default bundle @@ -80,12 +92,6 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace("EXIT!"); //NOI18N } - /** - * Default constructor - */ - public PizzaServiceApplication () { - } - /** * Calculates total amount of all choosen products * @@ -491,6 +497,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ @Override public Iterator getAvailableProducts () throws ServletException { + // categoryFrontend must be set + if (null == this.productFrontend) { + // Abort here + throw new NullPointerException("productFrontend is null"); + } + try { // Ask frontend for a list of products return this.productFrontend.getAvailableProducts(); @@ -506,6 +518,15 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ @Override public Iterator getAllProducts () throws ServletException { + // Trace message + this.getLogger().trace("CALLED!"); + + // categoryFrontend must be set + if (null == this.productFrontend) { + // Abort here + throw new NullPointerException("productFrontend is null"); + } + try { // Ask frontend for a list of products return this.productFrontend.getAllProducts(); @@ -521,6 +542,15 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ @Override public Iterator getCategories () throws ServletException { + // Trace message + this.getLogger().trace("CALLED!"); + + // categoryFrontend must be set + if (null == this.categoryFrontend) { + // Abort here + throw new NullPointerException("categoryFrontend is null"); + } + try { // Ask frontend for a list of categories return this.categoryFrontend.getCategories(); @@ -539,6 +569,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P * @return Amount as string */ @Override + @Deprecated public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) { // Trace message this.getLogger().trace(MessageFormat.format("product={0},request={1},session={2} - CALLED!", product, request, session)); //NOI18N @@ -1056,6 +1087,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P * @return Whether it has been found */ private boolean isCategoryTitleUsed(final String title) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + // categoryFrontend must be set + if (null == this.categoryFrontend) { + // Abort here + throw new NullPointerException("categoryFrontend is null"); + } + // Delegate to frontend return this.categoryFrontend.isCategoryTitleUsed(title); } @@ -1066,6 +1103,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P * @return Whether the product title has already been used */ private boolean isProductTitleUsed (final String title) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + // categoryFrontend must be set + if (null == this.productFrontend) { + // Abort here + throw new NullPointerException("productFrontend is null"); + } + // Delegate to frontend return this.productFrontend.isProductTitleUsed(title); } @@ -1126,8 +1169,8 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } // Get all fields - String title = request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE); - String parent = request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_PARENT); + String title = request.getParameter(CategoryFrontend.COLUMN_TITLE); + String parent = request.getParameter(CategoryFrontend.COLUMN_PARENT); // Debug message this.getLogger().debug(MessageFormat.format("title={0},parent={1}", title, parent)); //NOI18N @@ -1138,10 +1181,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Check all fields if (null == title) { // "title" not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", CategoryFrontend.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", CategoryFrontend.COLUMN_TITLE)); //NOI18N } else if ((parent != null) && (!parent.isEmpty())) { // "parent" is set, so check it try { @@ -1191,10 +1234,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } // Get title, price and category id - String title = request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE); - String price = request.getParameter(PizzaProductDatabaseConstants.COLUMN_PRICE); - String category = request.getParameter(PizzaProductDatabaseConstants.COLUMN_CATEGORY); - String available = request.getParameter(PizzaProductDatabaseConstants.COLUMN_AVAILABLE); + String title = request.getParameter(ProductFrontend.COLUMN_TITLE); + String price = request.getParameter(ProductFrontend.COLUMN_PRICE); + String category = request.getParameter(ProductFrontend.COLUMN_CATEGORY); + String available = request.getParameter(ProductFrontend.COLUMN_AVAILABLE); // Debug message this.getLogger().debug(MessageFormat.format("title={0},price={1},category={2},available={3}", title, price, category, available)); //NOI18N @@ -1206,31 +1249,31 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Check all fields if (null == title) { // "title" not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", ProductFrontend.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", ProductFrontend.COLUMN_TITLE)); //NOI18N } else if (null == price) { // "price" not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_PRICE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", ProductFrontend.COLUMN_PRICE)); //NOI18N } else if (price.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_PRICE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", ProductFrontend.COLUMN_PRICE)); //NOI18N } else if (null == category) { // "title" not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_CATEGORY)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", ProductFrontend.COLUMN_CATEGORY)); //NOI18N } else if (category.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_CATEGORY)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", ProductFrontend.COLUMN_CATEGORY)); //NOI18N } else if (null == available) { // "title" not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_AVAILABLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", ProductFrontend.COLUMN_AVAILABLE)); //NOI18N } else if (available.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_AVAILABLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", ProductFrontend.COLUMN_AVAILABLE)); //NOI18N } else if ((!"true".equals(available)) && (!"false".equals(available))) { //NOI18N // Invalid value - throw new IllegalArgumentException(MessageFormat.format("{0} is invalid: {1}", PizzaProductDatabaseConstants.COLUMN_AVAILABLE, available)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is invalid: {1}", ProductFrontend.COLUMN_AVAILABLE, available)); //NOI18N } // Parse numbers @@ -1357,7 +1400,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0} - CALLED!", request)); //NOI18N // Init title - String title = request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE); + String title = request.getParameter(ProductFrontend.COLUMN_TITLE); // request must not be null and "title" must be found and non-empty if (null == request) { @@ -1365,10 +1408,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P throw new NullPointerException("request is null"); //NOI18N } else if (null == title) { // title is not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", ProductFrontend.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", ProductFrontend.COLUMN_TITLE)); //NOI18N } // Default is not used @@ -1511,7 +1554,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P this.getLogger().trace(MessageFormat.format("request={0} - CALLED!", request)); //NOI18N // Init title - String title = request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE); + String title = request.getParameter(CategoryFrontend.COLUMN_TITLE); // request must not be null and "title" must be found and non-empty if (null == request) { @@ -1519,10 +1562,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P throw new NullPointerException("request is null"); //NOI18N } else if (null == title) { // title is not set - throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", CategoryFrontend.COLUMN_TITLE)); //NOI18N } else if (title.isEmpty()) { // Is left empty - throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("{0} is empty.", CategoryFrontend.COLUMN_TITLE)); //NOI18N } // Default is not used diff --git a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java index 85daa560..3645d04c 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/BaseBasket.java @@ -17,7 +17,6 @@ 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; @@ -45,6 +44,17 @@ public class BaseBasket extends BasePizzaServiceSys */ private static final long serialVersionUID = 784396762230845717L; + /** + * Protected constructor with session instance + * + * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If an unsupported backend has been configured + * @throws java.sql.SQLException If an SQL error occurs + */ + protected BaseBasket () throws UnsupportedDatabaseBackendException, SQLException { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + } + @Override public void init (final ServletContext context, final HttpSession session) throws UnsupportedDatabaseBackendException, SQLException { // Trace message @@ -76,17 +86,6 @@ public class BaseBasket extends BasePizzaServiceSys this.setFrontend(frontend); } - /** - * Protected constructor with session instance - * - * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If an unsupported backend has been configured - * @throws java.sql.SQLException If an SQL error occurs - */ - protected BaseBasket () throws UnsupportedDatabaseBackendException, SQLException { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - } - @Override public void addItem (final T item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Trace call @@ -164,29 +163,4 @@ public class BaseBasket extends BasePizzaServiceSys // Return it return isAdded; } - - /** - * 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 everything else - - // 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/item/ItemBasket.java b/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java index ae34890f..51aaa066 100644 --- a/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java +++ b/src/java/org/mxchange/pizzaapplication/basket/item/ItemBasket.java @@ -35,7 +35,6 @@ public class ItemBasket extends BaseBasket implements Basket< /** * Default constructor to be able to throw exceptions from super constructor - * @param context Context instance * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported * @throws java.sql.SQLException If an SQL error occurs */ diff --git a/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java b/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java index 00188ca3..539b0e7b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/PizzaBean.java @@ -19,10 +19,13 @@ package org.mxchange.pizzaapplication.beans; import java.io.Serializable; import java.util.Iterator; import javax.faces.FacesException; +import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.logging.log4j.Logger; +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; @@ -304,4 +307,31 @@ public interface PizzaBean extends Serializable { * @throws ServletException If something unexpected happened */ public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException; + + /** + * Getter for logger + * + * @return Logger + */ + public Logger getLogger (); + + /** + * @return the basket + */ + public BasketBean getBasket (); + + /** + * @param basket the basket to set + */ + public void setBasket (final BasketBean basket); + + /** + * @return the application + */ + public ServletContext getApplication (); + + /** + * @param application the application to set + */ + public void setApplication (final ServletContext application); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java b/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java index 7248b7d7..7ff4e8ba 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/PizzaServiceBean.java @@ -29,6 +29,8 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; import org.mxchange.pizzaapplication.application.PizzaApplication; @@ -69,32 +71,49 @@ public class PizzaServiceBean implements PizzaBean { */ private final PizzaApplication app; + /** + * Class' logger + */ + private final Logger LOG; + /** * Initializer block */ { // Get new application instance + LOG = LogManager.getLogger(this); + LOG.debug("INITIALIZER!"); this.app = new PizzaServiceApplication(); } + /** + * Default constructor + */ + public PizzaServiceBean () { + this.getLogger().trace("CALLED!"); + } + @Override @PostConstruct public void init () throws FacesException { + // Trace message + this.getLogger().trace("application=" + this.getApplication() + ",basket=" + this.getBasket() + " - CALLED!"); + + // Must not be null + if (this.getApplication() == null) { + // Abort here + throw new NullPointerException("application is null"); + } + try { // Call init method - this.app.init(this.application); + this.app.init(this.getApplication()); } catch (final UnsupportedDatabaseBackendException | SQLException | IOException | BadTokenException ex) { // Continue to throw throw new FacesException(ex); } } - /** - * Default constructor - */ - public PizzaServiceBean () { - } - /** * Calculates total amount of all choosen products * @@ -248,6 +267,7 @@ public class PizzaServiceBean implements PizzaBean { * @return Amount as string */ @Override + @Deprecated public float getTotalPositionPriceFromRequestSession (final Product product, final HttpServletRequest request, final HttpSession session) { return this.app.getTotalPositionPriceFromRequestSession(product, request, session); } @@ -381,4 +401,62 @@ public class PizzaServiceBean implements PizzaBean { public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException { this.app.doAdminHandleCategoryForms(request, response); } + + /** + * Getter for logger + * + * @return Logger + */ + @Override + public Logger getLogger () { + return this.LOG; + } + + /** + * @return the basket + */ + @Override + public BasketBean getBasket () { + // Trace message + this.getLogger().trace("basked=" + this.basket + " - EXIT!"); + + // Return it + return this.basket; + } + + /** + * @param basket the basket to set + */ + @Override + public void setBasket (final BasketBean basket) { + // Trace message + this.getLogger().trace("basked=" + basket + " - CALLED!"); + + // Set it here + this.basket = basket; + } + + /** + * @return the application + */ + @Override + public ServletContext getApplication () { + // Trace message + this.getLogger().trace("application=" + this.application + " - EXIT!"); + + // Return it + return this.application; + } + + /** + * @param application the application to set + */ + @Override + public void setApplication (final ServletContext application) { + // Trace message + this.getLogger().trace("application=" + application + " - CALLED!"); + + // Set it here + this.application = application; + } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java index 22d12224..c37e6322 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketBean.java @@ -21,6 +21,9 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import javax.faces.FacesException; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; +import org.apache.logging.log4j.Logger; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; import org.mxchange.pizzaapplication.item.AddableBasketItem; @@ -105,4 +108,31 @@ public interface BasketBean extends Serializable { * @return Human-readable message */ public String getMessageStringFromKey (final String key); + + /** + * Getter for logger + * + * @return Logger + */ + public Logger getLogger (); + + /** + * @return the application + */ + public ServletContext getApplication (); + + /** + * @param application the application to set + */ + public void setApplication (final ServletContext application); + + /** + * @return the session + */ + public HttpSession getSession (); + + /** + * @param session the session to set + */ + public void setSession (final HttpSession session); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java index 27a074ba..1a8f7663 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/ItemBasketBean.java @@ -20,13 +20,15 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import javax.annotation.PostConstruct; -import javax.enterprise.context.Dependent; +import javax.enterprise.context.SessionScoped; import javax.faces.FacesException; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.ServletContext; import javax.servlet.http.HttpSession; +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.jcore.exceptions.UnsupportedDatabaseBackendException; @@ -41,7 +43,7 @@ import org.mxchange.pizzaapplication.product.Product; * @author Roland Haeder */ @Named("basket") -@Dependent +@SessionScoped public class ItemBasketBean implements BasketBean { /** * Serial number @@ -60,19 +62,35 @@ public class ItemBasketBean implements BasketBean { @Inject private HttpSession session; + /** + * Class' logger + */ + private final Logger LOG; + /** * Instance of wrapped basket */ private final Basket basket; + /** + * Initializer block + */ + { + // Get new application instance + this.basket = new ItemBasket(); + LOG = LogManager.getLogger(this); + } + /** * Default constructor to be able to throw exceptions from super constructor * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the backend is unsupported * @throws java.sql.SQLException If an SQL error occurs + * @throws java.io.IOException If an IO Error occurs + * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found */ - public ItemBasketBean () throws UnsupportedDatabaseBackendException, SQLException { - // Get new application instance - this.basket = new ItemBasket(); + public ItemBasketBean () throws UnsupportedDatabaseBackendException, SQLException, IOException, BadTokenException { + // Trace message + this.getLogger().trace("CALLED!"); } @Override @@ -93,9 +111,12 @@ public class ItemBasketBean implements BasketBean { @Override @PostConstruct public void init () throws FacesException { + // Trace message + this.getLogger().trace("application=" + this.getApplication() + ",session=" + this.getSession() + " - CALLED!"); + try { // Init instance - this.basket.init(this.application, this.session); + this.basket.init(this.getApplication(), this.getSession()); } catch (final UnsupportedDatabaseBackendException | IOException | SQLException | BadTokenException ex) { // Continue to throw throw new FaceletException(ex); @@ -111,4 +132,46 @@ public class ItemBasketBean implements BasketBean { public boolean isItemAdded (final AddableBasketItem item) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { return this.basket.isItemAdded(item); } + + /** + * Getter for logger + * + * @return Logger + */ + @Override + public Logger getLogger () { + return this.LOG; + } + + /** + * @return the application + */ + @Override + public ServletContext getApplication () { + return this.application; + } + + /** + * @param application the application to set + */ + @Override + public void setApplication (final ServletContext application) { + this.application = application; + } + + /** + * @return the session + */ + @Override + public HttpSession getSession () { + return this.session; + } + + /** + * @param session the session to set + */ + @Override + public void setSession (final HttpSession session) { + this.session = session; + } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java index 12fc8fb6..238c15b3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerBean.java @@ -16,12 +16,284 @@ */ package org.mxchange.pizzaapplication.beans.customer; -import org.mxchange.pizzaapplication.customer.Customer; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; +import java.util.Map; +import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Gender; /** * An interface for customer beans * * @author Roland Haeder */ -public interface CustomerBean extends Customer { +public interface CustomerBean extends Serializable { + /** + * Returns an iterator of all values from this object + * + * @return An iterator + * @throws java.lang.NoSuchMethodException If the invoked method was not found + * @throws java.lang.IllegalAccessException If the method cannot be accessed + * @throws java.lang.reflect.InvocationTargetException Any other problems? + */ + public Iterator> iterator ()throws NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Some "getter" for translated gender of the contact + * + * @return Translated / human-readable gender + */ + public String getTranslatedGender (); + + /** + * Gender of the contact + * + * @return the gender + */ + public Gender getGender (); + + /** + * Gender of the contact + * + * @param gender the gender to set + */ + public void setGender (final Gender gender); + + /** + * First name + * + * @return the first name + */ + public String getFirstName (); + + /** + * First name + * + * @param firstName the first name to set + */ + public void setFirstName (final String firstName); + + /** + * Family name + * + * @return the familyName + */ + public String getFamilyName (); + + /** + * Family name + * + * @param familyName the familyName to set + */ + public void setFamilyName (final String familyName); + + /** + * Companyname + * + * @return the companyName + */ + public String getCompanyName (); + + /** + * Companyname + * + * @param companyName the companyName to set + */ + public void setCompanyName (final String companyName); + + /** + * Street + * + * @return the street + */ + public String getStreet (); + + /** + * Street + * + * @param street the street to set + */ + public void setStreet (final String street); + + /** + * House number + * + * @return the houseNumber + */ + public Long getHouseNumber (); + + /** + * House number + * + * @param houseNumber the houseNumber to set + */ + public void setHouseNumber (final Long houseNumber); + + /** + * ZIP code + * + * @return the zipCode + */ + public Long getZipCode (); + + /** + * ZIP code + * + * @param zipCode the zipCode to set + */ + public void setZipCode (final Long zipCode); + + /** + * City + * + * @return the city + */ + public String getCity (); + + /** + * City + * + * @param city the city to set + */ + public void setCity (final String city); + + /** + * Country code + * + * @return the countryCode + */ + public String getCountryCode (); + + /** + * Country code + * + * @param countryCode the countryCode to set + */ + public void setCountryCode (final String countryCode); + + /** + * Email address + * + * @return the emailAddress + */ + public String getEmailAddress (); + + /** + * Email address + * + * @param emailAddress the emailAddress to set + */ + public void setEmailAddress (final String emailAddress); + + /** + * Phone number + * + * @return the phoneNumber + */ + public String getPhoneNumber (); + + /** + * Phone number + * + * @param phoneNumber the phoneNumber to set + */ + public void setPhoneNumber (final String phoneNumber); + + /** + * Fax number + * + * @return the faxNumber + */ + public String getFaxNumber (); + + /** + * Fax number + * + * @param faxNumber the faxNumber to set + */ + public void setFaxNumber (final String faxNumber); + + /** + * Cellphone number + * + * @return the cellphoneNumber + */ + public String getCellphoneNumber (); + + /** + * Cellphone number + * + * @param cellphoneNumber the cellphoneNumber to set + */ + public void setCellphoneNumber (final String cellphoneNumber); + + /** + * Birth day + * + * @return the birthday + */ + public String getBirthday (); + + /** + * Birth day + * + * @param birthday the birthday to set + */ + public void setBirthday (final String birthday); + + /** + * Comments + * + * @return the comment + */ + public String getComment (); + + /** + * Comments + * + * @param comment the comment to set + */ + public void setComment (final String comment); + + /** + * Checks whether the contact is user's own data + * + * @return Own data? + */ + public boolean isOwnContact (); + + /** + * Shows the contact to the user + * + * @param client Client instance to call back + */ + public void show (final Client client); + + /** + * Some "getter for a value from given column name. This name will be + * translated into a method name and then this method is called. + * + * @param columnName Column name + * @return Value from field + * @throws IllegalArgumentException Some implementations may throw this + * @throws java.lang.NoSuchMethodException If the invoked method was not found + * @throws java.lang.IllegalAccessException If the method cannot be accessed + * @throws java.lang.reflect.InvocationTargetException Any other problems? + */ + public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException; + + /** + * Some "setter" for a value from given column name. You may wish to overwrite this method in your + * own class. + * + * @param columnName Column name + * @param value Value to set in object's field + * @throws IllegalArgumentException Some implementations may throw this + * @throws java.lang.NoSuchMethodException If the invoked method was not found + * @throws java.lang.IllegalAccessException If the method cannot be accessed + * @throws java.lang.reflect.InvocationTargetException Any other problems? + */ + public void setValueFromColumn (final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException; } diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerBean.java new file mode 100644 index 00000000..327a88f9 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaServiceCustomerBean.java @@ -0,0 +1,298 @@ +/* + * 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.beans.customer; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; +import java.util.Map; +import javax.enterprise.context.SessionScoped; +import javax.inject.Named; +import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; +import org.mxchange.pizzaapplication.beans.customer.CustomerBean; +import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer; + +/** + * A customer bean which hides the customer instance + * + * @author Roland Haeder + */ +@Named("customer") +@SessionScoped +public class PizzaServiceCustomerBean implements CustomerBean { + /** + * Serial number + */ + private static final long serialVersionUID = 543145347916L; + + /** + * Contact instance + */ + private Contact contact; + + /** + * Default constructor + */ + public PizzaServiceCustomerBean () { + // Instance customer + Contact customer = new PizzaServiceCustomer(); + + // Fake gender + customer.setGender(Gender.UNKNOWN); + + // And set it here + this.setContact(customer); + } + + @Override + public String getBirthday () { + // Deligate to "hidden" object + return this.getContact().getBirthday(); + } + + @Override + public void setBirthday (final String birthday) { + // Deligate to "hidden" object + this.getContact().setBirthday(birthday); + } + + @Override + public String getCellphoneNumber () { + // Deligate to "hidden" object + return this.getContact().getCellphoneNumber(); + } + + @Override + public void setCellphoneNumber (final String cellphoneNumber) { + // Deligate to "hidden" object + this.getContact().setCellphoneNumber(cellphoneNumber); + } + + @Override + public String getCity () { + // Deligate to "hidden" object + return this.getContact().getCity(); + } + + @Override + public void setCity (final String city) { + // Deligate to "hidden" object + this.getContact().setCity(city); + } + + @Override + public String getComment () { + // Deligate to "hidden" object + return this.getContact().getComment(); + } + + @Override + public void setComment (final String comment) { + // Deligate to "hidden" object + this.getContact().setComment(comment); + } + + @Override + public String getCompanyName () { + // Deligate to "hidden" object + return this.getContact().getCompanyName(); + } + + @Override + public void setCompanyName (final String companyName) { + // Deligate to "hidden" object + this.getContact().setCompanyName(companyName); + } + + @Override + public String getCountryCode () { + // Deligate to "hidden" object + return this.getContact().getCountryCode(); + } + + @Override + public void setCountryCode (final String countryCode) { + // Deligate to "hidden" object + this.getContact().setCountryCode(countryCode); + } + + @Override + public String getEmailAddress () { + // Deligate to "hidden" object + return this.getContact().getEmailAddress(); + } + + @Override + public void setEmailAddress (final String emailAddress) { + // Deligate to "hidden" object + this.getContact().setEmailAddress(emailAddress); + } + + @Override + public String getFamilyName () { + // Trace call + //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!"); + + // Deligate to "hidden" object + return this.getContact().getFamilyName(); + } + + @Override + public void setFamilyName (final String familyName) { + // Trace call + //* NOISY-DEBUG: */ this.getLogger().trace(MessageFormat.format("familyName={0} - CALLED!", familyName)); + + // Deligate to "hidden" object + this.getContact().setFamilyName(familyName); + } + + @Override + public String getFaxNumber () { + // Deligate to "hidden" object + return this.getContact().getFaxNumber(); + } + + @Override + public void setFaxNumber (final String faxNumber) { + // Deligate to "hidden" object + this.getContact().setFaxNumber(faxNumber); + } + + @Override + public Gender getGender () { + // Deligate to "hidden" object + return this.getContact().getGender(); + } + + @Override + public void setGender (final Gender gender) { + // Deligate to "hidden" object + this.getContact().setGender(gender); + } + + @Override + public Long getHouseNumber () { + // Deligate to "hidden" object + return this.getContact().getHouseNumber(); + } + + @Override + public void setHouseNumber (final Long houseNumber) { + // Deligate to "hidden" object + this.getContact().setHouseNumber(houseNumber); + } + + @Override + public String getPhoneNumber () { + // Deligate to "hidden" object + return this.getContact().getPhoneNumber(); + } + + @Override + public void setPhoneNumber (final String phoneNumber) { + // Deligate to "hidden" object + this.getContact().setPhoneNumber(phoneNumber); + } + + @Override + public String getStreet () { + // Deligate to "hidden" object + return this.getContact().getStreet(); + } + + @Override + public void setStreet (final String street) { + // Deligate to "hidden" object + this.getContact().setStreet(street); + } + + @Override + public String getFirstName () { + // Deligate to "hidden" object + return this.getContact().getFirstName(); + } + + @Override + public void setFirstName (final String firstName) { + // Deligate to "hidden" object + this.getContact().setFirstName(firstName); + } + + @Override + public String getTranslatedGender () { + // Deligate to "hidden" object + return this.getContact().getTranslatedGender(); + } + + @Override + public Long getZipCode () { + // Deligate to "hidden" object + return this.getContact().getZipCode(); + } + + @Override + public void setZipCode (final Long zipCode) { + // Deligate to "hidden" object + this.getContact().setZipCode(zipCode); + } + + @Override + public boolean isOwnContact () { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Iterator> iterator () throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Deligate to "hidden" object + return this.getContact().iterator(); + } + + @Override + public void show (final Client client) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Deligate to "hidden" object + return this.getContact().getValueFromColumn(columnName); + } + + @Override + public void setValueFromColumn (final String columnName, final Object value) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Deligate to "hidden" object + this.getContact().setValueFromColumn(columnName, value); + } + + /** + * Setter for Contact instance + * @param contact Contact instance to set + */ + private void setContact (final Contact contact) { + this.contact = contact; + } + + /** + * Getter for Contact instance + * @return Contact instance + */ + private Contact getContact () { + return this.contact; + } +} diff --git a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java deleted file mode 100644 index d2fb8d70..00000000 --- a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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.customer.bean; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; -import java.util.Map; -import org.mxchange.jcore.client.Client; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.contact.Gender; -import org.mxchange.pizzaapplication.BasePizzaServiceSystem; -import org.mxchange.pizzaapplication.beans.customer.CustomerBean; -import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer; - -/** - * A customer bean which hides the customer instance - * - * @author Roland Haeder - */ -public class PizzaServiceCustomerBean extends BasePizzaServiceSystem implements CustomerBean { - /** - * Default constructor - */ - public PizzaServiceCustomerBean () { - // Instance customer - Contact customer = new PizzaServiceCustomer(); - - // Fake gender - customer.setGender(Gender.UNKNOWN); - - // And set it here - this.setContact(customer); - } - - @Override - public String getBirthday () { - // Deligate to "hidden" object - return this.getContact().getBirthday(); - } - - @Override - public void setBirthday (final String birthday) { - // Deligate to "hidden" object - this.getContact().setBirthday(birthday); - } - - @Override - public String getCellphoneNumber () { - // Deligate to "hidden" object - return this.getContact().getCellphoneNumber(); - } - - @Override - public void setCellphoneNumber (final String cellphoneNumber) { - // Deligate to "hidden" object - this.getContact().setCellphoneNumber(cellphoneNumber); - } - - @Override - public String getCity () { - // Deligate to "hidden" object - return this.getContact().getCity(); - } - - @Override - public void setCity (final String city) { - // Deligate to "hidden" object - this.getContact().setCity(city); - } - - @Override - public String getComment () { - // Deligate to "hidden" object - return this.getContact().getComment(); - } - - @Override - public void setComment (final String comment) { - // Deligate to "hidden" object - this.getContact().setComment(comment); - } - - @Override - public String getCompanyName () { - // Deligate to "hidden" object - return this.getContact().getCompanyName(); - } - - @Override - public void setCompanyName (final String companyName) { - // Deligate to "hidden" object - this.getContact().setCompanyName(companyName); - } - - @Override - public String getCountryCode () { - // Deligate to "hidden" object - return this.getContact().getCountryCode(); - } - - @Override - public void setCountryCode (final String countryCode) { - // Deligate to "hidden" object - this.getContact().setCountryCode(countryCode); - } - - @Override - public String getEmailAddress () { - // Deligate to "hidden" object - return this.getContact().getEmailAddress(); - } - - @Override - public void setEmailAddress (final String emailAddress) { - // Deligate to "hidden" object - this.getContact().setEmailAddress(emailAddress); - } - - @Override - public String getFamilyName () { - // Trace call - //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!"); - - // Deligate to "hidden" object - return this.getContact().getFamilyName(); - } - - @Override - public void setFamilyName (final String familyName) { - // Trace call - //* NOISY-DEBUG: */ this.getLogger().trace(MessageFormat.format("familyName={0} - CALLED!", familyName)); - - // Deligate to "hidden" object - this.getContact().setFamilyName(familyName); - } - - @Override - public String getFaxNumber () { - // Deligate to "hidden" object - return this.getContact().getFaxNumber(); - } - - @Override - public void setFaxNumber (final String faxNumber) { - // Deligate to "hidden" object - this.getContact().setFaxNumber(faxNumber); - } - - @Override - public Gender getGender () { - // Deligate to "hidden" object - return this.getContact().getGender(); - } - - @Override - public void setGender (final Gender gender) { - // Deligate to "hidden" object - this.getContact().setGender(gender); - } - - @Override - public Long getHouseNumber () { - // Deligate to "hidden" object - return this.getContact().getHouseNumber(); - } - - @Override - public void setHouseNumber (final Long houseNumber) { - // Deligate to "hidden" object - this.getContact().setHouseNumber(houseNumber); - } - - @Override - public String getPhoneNumber () { - // Deligate to "hidden" object - return this.getContact().getPhoneNumber(); - } - - @Override - public void setPhoneNumber (final String phoneNumber) { - // Deligate to "hidden" object - this.getContact().setPhoneNumber(phoneNumber); - } - - @Override - public String getStreet () { - // Deligate to "hidden" object - return this.getContact().getStreet(); - } - - @Override - public void setStreet (final String street) { - // Deligate to "hidden" object - this.getContact().setStreet(street); - } - - @Override - public String getFirstName () { - // Deligate to "hidden" object - return this.getContact().getFirstName(); - } - - @Override - public void setFirstName (final String firstName) { - // Deligate to "hidden" object - this.getContact().setFirstName(firstName); - } - - @Override - public String getTranslatedGender () { - // Deligate to "hidden" object - return this.getContact().getTranslatedGender(); - } - - @Override - public Long getZipCode () { - // Deligate to "hidden" object - return this.getContact().getZipCode(); - } - - @Override - public void setZipCode (final Long zipCode) { - // Deligate to "hidden" object - this.getContact().setZipCode(zipCode); - } - - @Override - public boolean isOwnContact () { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Iterator> iterator () throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - // Deligate to "hidden" object - return this.getContact().iterator(); - } - - @Override - public void show (final Client client) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - // Deligate to "hidden" object - return this.getContact().getValueFromColumn(columnName); - } - - @Override - public void setValueFromColumn (final String columnName, final Object value) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - // Deligate to "hidden" object - this.getContact().setValueFromColumn(columnName, value); - } -} diff --git a/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java deleted file mode 100644 index 4fde31e2..00000000 --- a/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.category; - -/** - * Holder class for database columns for product frontend - * - * @author Roland Haeder - */ -public final class PizzaCategoryDatabaseConstants { - /** - * Column name for "id" - */ - public static final String COLUMN_ID = "category_id"; //NOI18N - - /** - * Column name for "parent" - */ - public static final String COLUMN_PARENT = "parent"; //NOI18N - - /** - * Column name for "title" - */ - public static final String COLUMN_TITLE = "title"; //NOI18N - - /** - * No instance from this class - */ - private PizzaCategoryDatabaseConstants () { - } -} 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 f6d8b380..82c65396 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/category/CategoryFrontend.java @@ -32,6 +32,18 @@ import org.mxchange.pizzaapplication.product.Product; * @author Roland Häder */ public interface CategoryFrontend extends DatabaseFrontend { + /** + * Column name for "parent" + */ + public static final String COLUMN_PARENT = "parent"; //NOI18N + /** + * Column name for "title" + */ + public static final String COLUMN_TITLE = "title"; //NOI18N + /** + * Column name for "id" + */ + public static final String COLUMN_ID = "category_id"; //NOI18N /** * Adds given category title as new category, parent may be null if not 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 aea48416..081484f5 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java @@ -34,7 +34,6 @@ import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; import org.mxchange.pizzaapplication.category.Category; import org.mxchange.pizzaapplication.category.product.ProductCategory; -import org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants; import org.mxchange.pizzaapplication.product.Product; /** @@ -83,8 +82,8 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen this.clearDataSet(); // Add title and parent - this.addToDataSet(PizzaCategoryDatabaseConstants.COLUMN_TITLE, title); - this.addToDataSet(PizzaCategoryDatabaseConstants.COLUMN_PARENT, parent); + this.addToDataSet(CategoryFrontend.COLUMN_TITLE, title); + this.addToDataSet(CategoryFrontend.COLUMN_PARENT, parent); // Handle this over to the backend // @todo Nothing is done yet! @@ -134,7 +133,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen if ((value instanceof String) && ("".equals(value))) { //NOI18N // This value may need to be changed switch (key) { - case PizzaCategoryDatabaseConstants.COLUMN_PARENT: // Convert this + case CategoryFrontend.COLUMN_PARENT: // Convert this v = null; break; } @@ -196,7 +195,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen SearchableCriteria criteria = new SearchCriteria(); // Add id to it - criteria.addCriteria(PizzaCategoryDatabaseConstants.COLUMN_ID, id); + criteria.addCriteria(CategoryFrontend.COLUMN_ID, id); // Only one entry is find criteria.setLimit(1); @@ -235,7 +234,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen @Override public String getIdName () { // Return column id - return PizzaCategoryDatabaseConstants.COLUMN_ID; + return CategoryFrontend.COLUMN_ID; } /** @@ -259,9 +258,9 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen // "Walk" through all entries while (resultSet.next()) { // Get id, title and parent id - Long id = resultSet.getLong(PizzaCategoryDatabaseConstants.COLUMN_ID); - String title = resultSet.getString(PizzaCategoryDatabaseConstants.COLUMN_TITLE); - Long parent = resultSet.getLong(PizzaCategoryDatabaseConstants.COLUMN_PARENT); + Long id = resultSet.getLong(CategoryFrontend.COLUMN_ID); + String title = resultSet.getString(CategoryFrontend.COLUMN_TITLE); + Long parent = resultSet.getLong(CategoryFrontend.COLUMN_PARENT); // Debug message this.getLogger().debug(MessageFormat.format("id={0},title={1},parent={2}", id, title, parent)); //NOI18N @@ -303,7 +302,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen SearchableCriteria criteria = new SearchCriteria(); // Add criteria - criteria.addCriteria(PizzaCategoryDatabaseConstants.COLUMN_TITLE, title); + criteria.addCriteria(CategoryFrontend.COLUMN_TITLE, title); // Only one entry is find criteria.setLimit(1); 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 6059cf46..1c9008a9 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java @@ -32,7 +32,6 @@ 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.product.PizzaProductDatabaseConstants; import org.mxchange.pizzaapplication.product.Product; import org.mxchange.pizzaapplication.product.pizza.PizzaProduct; @@ -91,10 +90,10 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement this.clearDataSet(); // Add title and parent - this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_TITLE, title); - this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_PRICE, price); - this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_CATEGORY, category); - this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, available); + 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! @@ -197,7 +196,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement SearchableCriteria criteria = new SearchCriteria(); // Add criteria - criteria.addCriteria(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, true); + criteria.addCriteria(ProductFrontend.COLUMN_AVAILABLE, true); // Run the query Result result = this.getBackend().doSelectByCriteria(criteria); @@ -218,7 +217,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement @Override public String getIdName () { // Return column id - return PizzaProductDatabaseConstants.COLUMN_ITEM_ID; + return ProductFrontend.COLUMN_ITEM_ID; } /** @@ -242,11 +241,11 @@ 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_ITEM_ID); - String title = resultSet.getString(PizzaProductDatabaseConstants.COLUMN_TITLE); - Float price = resultSet.getFloat(PizzaProductDatabaseConstants.COLUMN_PRICE); - Long category = resultSet.getLong(PizzaProductDatabaseConstants.COLUMN_CATEGORY); - Boolean available = resultSet.getBoolean(PizzaProductDatabaseConstants.COLUMN_AVAILABLE); + Long id = resultSet.getLong(ProductFrontend.COLUMN_ITEM_ID); + String title = resultSet.getString(ProductFrontend.COLUMN_TITLE); + Float price = resultSet.getFloat(ProductFrontend.COLUMN_PRICE); + Long category = resultSet.getLong(ProductFrontend.COLUMN_CATEGORY); + Boolean available = resultSet.getBoolean(ProductFrontend.COLUMN_AVAILABLE); // Debug message this.getLogger().debug(MessageFormat.format("id={0},title={1},category={2},available={3}", id, title, category, available)); //NOI18N @@ -291,7 +290,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement SearchableCriteria criteria = new SearchCriteria(); // Add criteria - criteria.addCriteria(PizzaProductDatabaseConstants.COLUMN_TITLE, title); + criteria.addCriteria(ProductFrontend.COLUMN_TITLE, title); // Only one entry is find criteria.setLimit(1); 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 cb4146a3..6cc26149 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/ProductFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/ProductFrontend.java @@ -31,6 +31,26 @@ import org.mxchange.pizzaapplication.product.Product; * @author Roland Häder */ public interface ProductFrontend extends DatabaseFrontend { + /** + * Column name for "item_id" + */ + public static final String COLUMN_ITEM_ID = "item_id"; //NOI18N + /** + * Column name for "available" + */ + public static final String COLUMN_AVAILABLE = "available"; //NOI18N + /** + * Column name for "price" + */ + public static final String COLUMN_PRICE = "price"; //NOI18N + /** + * Column name for "category" + */ + public static final String COLUMN_CATEGORY = "category"; //NOI18N + /** + * Column name for "title" + */ + public static final String COLUMN_TITLE = "title"; //NOI18N /** * Adds product to database by given title, price and category id diff --git a/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java deleted file mode 100644 index d10a80e4..00000000 --- a/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.product; - -/** - * Holder class for database columns for product frontend - * - * @author Roland Haeder - */ -public final class PizzaProductDatabaseConstants { - /** - * Column name for "available" - */ - public static final String COLUMN_AVAILABLE = "available"; //NOI18N - - /** - * Column name for "category" - */ - public static final String COLUMN_CATEGORY = "category"; //NOI18N - - /** - * Column name for "item_id" - */ - public static final String COLUMN_ITEM_ID = "item_id"; //NOI18N - - /** - * Column name for "price" - */ - public static final String COLUMN_PRICE = "price"; //NOI18N - - /** - * Column name for "title" - */ - public static final String COLUMN_TITLE = "title"; //NOI18N - - /** - * No instance from this class - */ - private PizzaProductDatabaseConstants () { - } -} diff --git a/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java b/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java index 08d4ceaa..5295d62c 100644 --- a/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java +++ b/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java @@ -18,7 +18,7 @@ package org.mxchange.pizzaapplication.exceptions; import java.text.MessageFormat; import javax.servlet.http.HttpServletRequest; -import org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants; +import org.mxchange.pizzaapplication.database.frontend.category.CategoryFrontend; /** * An exception thrown when the given title is already used @@ -34,7 +34,6 @@ public class CategoryTitleAlreadyUsedException extends Exception { */ public CategoryTitleAlreadyUsedException (final HttpServletRequest request) { // Call super constructor - super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE))); //NOI18N + super(MessageFormat.format("Title {0} is already used.", request.getParameter(CategoryFrontend.COLUMN_TITLE))); //NOI18N } - } diff --git a/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java b/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java index 568ba391..c36c59f5 100644 --- a/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java +++ b/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java @@ -18,7 +18,7 @@ package org.mxchange.pizzaapplication.exceptions; import java.text.MessageFormat; import javax.servlet.http.HttpServletRequest; -import org.mxchange.pizzaapplication.database.product.PizzaProductDatabaseConstants; +import org.mxchange.pizzaapplication.database.frontend.product.ProductFrontend; /** * An exception thrown when the given title is already used @@ -34,7 +34,6 @@ public class ProductTitleAlreadyUsedException extends Exception { */ public ProductTitleAlreadyUsedException (final HttpServletRequest request) { // Call super constructor - super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE))); //NOI18N + super(MessageFormat.format("Title {0} is already used.", request.getParameter(ProductFrontend.COLUMN_TITLE))); //NOI18N } - } diff --git a/src/java/org/mxchange/pizzaapplication/tags/basket/BasketTag.java b/src/java/org/mxchange/pizzaapplication/tags/basket/BasketTag.java new file mode 100644 index 00000000..645f0b2b --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/tags/basket/BasketTag.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2015 quix0r + * + * 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.tags.basket; + +import javax.servlet.jsp.tagext.BodyTag; +import org.mxchange.pizzaapplication.beans.basket.BasketBean; + +/** + * + * @author quix0r + */ +public interface BasketTag extends BodyTag { + + /** + * @return the basket + */ + public BasketBean getBasket (); + + /** + * @param basket the basket to set + */ + public void setBasket (final BasketBean basket); +} diff --git a/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java b/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java index d3c36ba4..1ec420a3 100644 --- a/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java +++ b/src/java/org/mxchange/pizzaapplication/tags/basket/MiniBasketTag.java @@ -19,8 +19,6 @@ package org.mxchange.pizzaapplication.tags.basket; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; -import javax.enterprise.context.SessionScoped; -import javax.inject.Inject; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyTagSupport; import org.mxchange.jcore.exceptions.BadTokenException; @@ -32,12 +30,15 @@ import org.mxchange.pizzaapplication.beans.basket.BasketBean; * * @author Roland Haeder */ -@SessionScoped -public class MiniBasketTag extends BodyTagSupport { +public class MiniBasketTag extends BodyTagSupport implements BasketTag { + /** + * Serial number + */ + private static final long serialVersionUID = 457415727452384L; + /** * Basket instance */ - @Inject private BasketBean basket; /** @@ -53,17 +54,17 @@ public class MiniBasketTag extends BodyTagSupport { StringBuilder out = new StringBuilder("
\n"); // basket should not be null - if (this.basket == null) { + if (this.getBasket() == null) { // Not set throw new NullPointerException("basket instance is null"); } try { // Some entries found? - if (this.basket.isEmpty()) { + if (this.getBasket().isEmpty()) { // Empty basket out.append("
\n"); - out.append(this.basket.getMessageStringFromKey("MiniBasketTag.basket_is_empty")).append("\n"); + out.append(this.getBasket().getMessageStringFromKey("MiniBasketTag.basket_is_empty")).append("\n"); out.append("
\n"); } else { // Some times were found @@ -79,7 +80,7 @@ public class MiniBasketTag extends BodyTagSupport { try { // Get output instance and write it - pageContext.getOut().print(out.toString()); + this.pageContext.getOut().print(out.toString()); } catch (final IOException ex) { // Continue to throw throw new JspException(ex); @@ -88,4 +89,20 @@ public class MiniBasketTag extends BodyTagSupport { // Don't process any body return SKIP_BODY; } + + /** + * @return the basket + */ + @Override + public BasketBean getBasket () { + return this.basket; + } + + /** + * @param basket the basket to set + */ + @Override + public void setBasket (final BasketBean basket) { + this.basket = basket; + } } diff --git a/web/WEB-INF/tlds/basket.tld b/web/WEB-INF/tlds/basket.tld index 6eed62f3..cd63a914 100644 --- a/web/WEB-INF/tlds/basket.tld +++ b/web/WEB-INF/tlds/basket.tld @@ -9,5 +9,12 @@ mini_basket A mini basket showing latest added item and a link to the full basket web page org.mxchange.pizzaapplication.tags.basket.MiniBasketTag + + basket + Basket instance, should be the same as the bean + true + true + org.mxchange.pizzaapplication.beans.basket.BasketBean + diff --git a/web/admin/category.jsp b/web/admin/category.jsp index 3f9c0369..03817a13 100644 --- a/web/admin/category.jsp +++ b/web/admin/category.jsp @@ -7,15 +7,11 @@ <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%--<%@page errorPage="errorHandler.jsp" %>--%> <%@page import="org.mxchange.pizzaapplication.category.Category"%> -<%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%> +<%@page import="org.mxchange.pizzaapplication.database.frontend.category.CategoryFrontend"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> - -<% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); -%> + @@ -58,10 +54,10 @@ - + - + ${category.decodedTitle()} @@ -101,7 +97,7 @@
- +
diff --git a/web/admin/index.jsp b/web/admin/index.jsp index 778b6b21..d60e08de 100644 --- a/web/admin/index.jsp +++ b/web/admin/index.jsp @@ -11,11 +11,8 @@ <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> <%@page import="org.mxchange.pizzaapplication.product.Product"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> + -<% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); -%> diff --git a/web/admin/product.jsp b/web/admin/product.jsp index cac2d9d9..399fe98f 100644 --- a/web/admin/product.jsp +++ b/web/admin/product.jsp @@ -13,12 +13,9 @@ <%@page import="org.mxchange.pizzaapplication.product.Product"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> -<%@page import="org.mxchange.pizzaapplication.database.product.PizzaProductDatabaseConstants"%> +<%@page import="org.mxchange.pizzaapplication.database.frontend.product.ProductFrontend"%> + -<% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); -%> @@ -66,7 +63,7 @@ - + ${product.getItemId()}: @@ -115,7 +112,7 @@
- +
@@ -128,7 +125,7 @@
- +
diff --git a/web/form_handler/add_item.jsp b/web/form_handler/add_item.jsp index 4a9fb126..aa07ebf6 100644 --- a/web/form_handler/add_item.jsp +++ b/web/form_handler/add_item.jsp @@ -4,24 +4,24 @@ Author : Roland Haeder --%> +<%@page import="org.mxchange.jcore.BaseFrameworkSystem"%> <%--<%@page errorPage="errorHandler.jsp" %>--%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> <%@page import="org.mxchange.pizzaapplication.item.AddableBasketItem"%> + + <% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); - // Get amount from item Long amount = item.getAmount(); // Debug message - app.getLogger().debug("amount=" + amount); + BaseFrameworkSystem.getInstance().getLogger().debug("amount=" + amount); // Is amount null or zero? if ((null == amount) || (amount == 0)) { diff --git a/web/form_handler/admin/do_category.jsp b/web/form_handler/admin/do_category.jsp index ca3fa531..c4cf37df 100644 --- a/web/form_handler/admin/do_category.jsp +++ b/web/form_handler/admin/do_category.jsp @@ -8,16 +8,14 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> -<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %> +<%@page import="org.mxchange.pizzaapplication.beans.customer.CustomerBean" %> <%@page import="org.mxchange.pizzaapplication.product.Product"%> <%@page import="org.mxchange.pizzaapplication.exceptions.CategoryTitleAlreadyUsedException"%> + <% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); - // Handle forms - app.doAdminHandleCategoryForms(request, response); + controller.doAdminHandleCategoryForms(request, response); %> diff --git a/web/form_handler/admin/do_product.jsp b/web/form_handler/admin/do_product.jsp index f806c874..d912531b 100644 --- a/web/form_handler/admin/do_product.jsp +++ b/web/form_handler/admin/do_product.jsp @@ -8,15 +8,13 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> -<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %> +<%@page import="org.mxchange.pizzaapplication.beans.customer.CustomerBean" %> <%@page import="org.mxchange.pizzaapplication.product.Product"%> + <% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); - // Handle forms - app.doAdminHandleProductForms(request, response); + controller.doAdminHandleProductForms(request, response); %> diff --git a/web/form_handler/do_order.jsp b/web/form_handler/do_order.jsp deleted file mode 100644 index a6006607..00000000 --- a/web/form_handler/do_order.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- - Document : order - Created on : 07.08.2015, 14:58:21 - Author : Roland Haeder ---%> - -<%--<%@page errorPage="errorHandler.jsp" %>--%> -<%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> -<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> -<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %> -<%@page import="org.mxchange.pizzaapplication.product.Product"%> - -<% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); - - // Is it post? - if ("POST".equals(request.getMethod())) { //NOI18N - // @TODO Handle saving customer data and such things - - // Mark all choosen products as ordered - app.markAllChoosenProductsAsOrdered(request, session); - - // Redirect to proper URL - // @TODO Commented out for developing: - //response.sendRedirect(request.getContextPath() + "/finished.jsp"); -%> - - - -<% - } -%> - - - - - - - Pizza-Service - Form-Handler - - - -
-

Pizza-Service - Form-Handler

-
- - - - - - diff --git a/web/form_handler/do_preview.jsp b/web/form_handler/do_preview.jsp deleted file mode 100644 index f4b7f13d..00000000 --- a/web/form_handler/do_preview.jsp +++ /dev/null @@ -1,71 +0,0 @@ -<%-- - Document : order - Created on : 04.08.2015, 10:55:10 - Author : Roland Haeder ---%> - -<%--<%@page errorPage="errorHandler.jsp" %>--%> -<%@page import="java.util.Iterator"%> -<%@page import="java.util.Map"%> -<%@page import="org.mxchange.jcore.contact.Gender"%> -<%@page import="org.mxchange.pizzaapplication.product.Product"%> -<%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> -<%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> -<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %> -<%@page contentType="text/html" pageEncoding="UTF-8"%> - -<% - // Init application instance - PizzaBean app = PizzaServiceBean.getInstance(application); - - // Is it post? - if ("POST".equals(request.getMethod())) { //NOI18N - // Get Iterator - Iterator iterator = app.getAvailableProducts(); - - // "Walk" through all products and unmark them as ordered - while (iterator.hasNext()) { - // Get product instance - Product product = iterator.next(); - - // Mark product as not ordered - app.unmarkProductAsOrdered(product, session); - - // Is it choosen and amount set? - if (app.isProductChoosen(product, request, session)) { - // Then mark it as choosen - app.markProductAsChoosen(product, session); - } else { - // Unmark it - app.unmarkProductAsChoosen(product, session); - } - } - - // Redirect to proper URL - // @TODO Commented out for developing: - //response.sendRedirect(request.getContextPath() + "/finished.jsp"); -%> - - - -<% - } -%> - - - - - - Pizza-Service - Form-Handler - - - -
-

Pizza-Service - Form-Handler

-
- - - - - - diff --git a/web/index.jsp b/web/index.jsp index f3c27c5a..b5e641aa 100644 --- a/web/index.jsp +++ b/web/index.jsp @@ -4,10 +4,10 @@ Author : Roland Haeder --%> -<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%> <%--<%@page errorPage="errorHandler.jsp" %>--%> <%@page import="java.util.Map"%> <%@page import="java.util.Iterator"%> +<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> <%@page import="org.mxchange.pizzaapplication.product.Product"%> <%@page import="org.mxchange.pizzaapplication.basket.Basket"%> @@ -16,8 +16,7 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@taglib prefix="basket" uri="http://mxchange.org/pizza-service/tags/basket" %> - - + @@ -42,7 +41,7 @@
- + @@ -63,7 +62,7 @@ <% // Get Iterator - Iterator iterator = service.getAvailableProducts(); + Iterator iterator = controller.getAvailableProducts(); // "Walk" through all products and unmark them as ordered while (iterator.hasNext()) { @@ -74,7 +73,7 @@ product.getLogger().debug("product.itemId=" + product.getItemId()); // Create an item instance form this product - AddableBasketItem item = basket.getItem(product); + AddableBasketItem item = controller.getBasket().getItem(product); // Debug message product.getLogger().debug("item=" + item); @@ -105,9 +104,6 @@ // Then skip this item continue; } - - // Unmark as ordered - service.unmarkProductAsOrdered(product, session); %>
diff --git a/web/static/admin/admin_category_selection_box.jsp b/web/static/admin/admin_category_selection_box.jsp index 908bc072..5d7672b2 100644 --- a/web/static/admin/admin_category_selection_box.jsp +++ b/web/static/admin/admin_category_selection_box.jsp @@ -5,13 +5,13 @@ --%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%> +<%@page import="org.mxchange.pizzaapplication.database.frontend.category.CategoryFrontend"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> - + - + diff --git a/web/static/admin/admin_parent_category_selection_box.jsp b/web/static/admin/admin_parent_category_selection_box.jsp index 877396a6..845dcae4 100644 --- a/web/static/admin/admin_parent_category_selection_box.jsp +++ b/web/static/admin/admin_parent_category_selection_box.jsp @@ -5,14 +5,14 @@ --%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@page import="org.mxchange.pizzaapplication.database.category.PizzaCategoryDatabaseConstants"%> +<%@page import="org.mxchange.pizzaapplication.database.frontend.category.CategoryFrontend"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaServiceBean"%> <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%> - + - - + diff --git a/web/static/gender_selection_box.jsp b/web/static/gender_selection_box.jsp index 615ef9e9..09379be6 100644 --- a/web/static/gender_selection_box.jsp +++ b/web/static/gender_selection_box.jsp @@ -9,9 +9,9 @@ <%@page import="org.mxchange.pizzaapplication.beans.customer.CustomerBean" %> - + -> <% // "Walk" through all genders and output them for (final Gender gender : Gender.values()) {