]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Renamed beans to their proper scope + renamed bean mappedName to always end with...
authorRoland Haeder <roland@mxchange.org>
Mon, 19 Oct 2015 07:34:28 +0000 (09:34 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 19 Oct 2015 07:34:28 +0000 (09:34 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

40 files changed:
src/java/org/mxchange/jshopcore/model/category/CategoryConverter.java
src/java/org/mxchange/pizzaapplication/beans/AbstractWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/country/CountryWebApplicationBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/country/CountryWebApplicationController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebApplicationBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebApplicationController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebController.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebApplicationBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebApplicationController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebController.java [deleted file]
web/WEB-INF/templates/admin/admin_category_selection_box.tpl
web/admin/product.xhtml

index b811c9b5011947b690c2c0cb24895c1874bffa93..8ada370971277c4851c4eb8f60998497fa211dc9 100644 (file)
@@ -30,7 +30,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreeelogger.beans.local.logger.Log;
 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.pizzaapplication.beans.shop.ShopWebController;
+import org.mxchange.pizzaapplication.beans.shop.ShopWebApplicationController;
 
 /**
  * A converter for transfering category objects
@@ -50,7 +50,7 @@ public class CategoryConverter implements Converter {
         * Category bean
         */
        @Inject
-       private ShopWebController shopController;
+       private ShopWebApplicationController shopController;
 
        @Override
        public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
diff --git a/src/java/org/mxchange/pizzaapplication/beans/AbstractWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/AbstractWebBean.java
deleted file mode 100644 (file)
index 1e632c5..0000000
+++ /dev/null
@@ -1,74 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans;
-
-import java.io.Serializable;
-import java.util.ResourceBundle;
-
-/**
- * An abstract web web bean for web applications. This class currently only
- * handles loading the resource bundle (i18n).
- * <p>
- * @author Roland Haeder
- */
-public abstract class AbstractWebBean implements Serializable {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 48_475_834_783_473_187L;
-
-       /**
-        * Bundle instance
-        */
-       private final ResourceBundle bundle;
-
-       /**
-        * Protectd constructor
-        */
-       protected AbstractWebBean () {
-               // Load resource bundle
-               this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle");
-       }
-
-       /**
-        * Getter for bundle instance
-        * <p>
-        * @return Bundle instance
-        */
-       protected ResourceBundle getBundle () {
-               return this.bundle;
-       }
-
-       /**
-        * Getter for message from given key
-        * <p>
-        * @param key Key to get message from
-        * <p>
-        * @return Message
-        */
-       protected String getMessageStringFromKey (final String key) {
-               // Is the bundle loaded?
-               if (this.getBundle() == null) {
-                       // Abort here
-                       throw new NullPointerException("bundle is null"); //NOI18N
-               }
-
-               // Return message
-               return this.getBundle().getString(key);
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java
deleted file mode 100644 (file)
index edf197f..0000000
+++ /dev/null
@@ -1,479 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.basket;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.enterprise.context.SessionScoped;
-import javax.faces.FacesException;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException;
-import org.mxchange.jshopcore.model.basket.AddableBasketItem;
-import org.mxchange.jshopcore.model.basket.Basket;
-import org.mxchange.jshopcore.model.basket.BasketSessionBeanRemote;
-import org.mxchange.jshopcore.model.basket.ShopBasket;
-import org.mxchange.jshopcore.model.basket.items.BasketItem;
-import org.mxchange.jshopcore.model.product.Product;
-
-/**
- * A bean for the basket
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("basketController")
-@SessionScoped
-public class BasketWebBean implements BasketWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 5_476_347_320_198L;
-
-       /**
-        * Instance of wrapped basket
-        */
-       private final Basket<AddableBasketItem> basket;
-
-       /**
-        * Basket bean
-        */
-       private final BasketSessionBeanRemote basketBean;
-
-
-       /**
-        * Current item
-        */
-       private AddableBasketItem currentItem;
-
-       /////////////////////// Properties /////////////////////
-       /**
-        * Ordered orderedAmount
-        */
-       private Long orderedAmount;
-
-       /**
-        * Default constructor
-        */
-       public BasketWebBean () {
-               // Get new application instance
-               this.basket = new ShopBasket();
-
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.basketBean = (BasketSessionBeanRemote) context.lookup("ejb/stateless-basket"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public String addItem (final Product product) {
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("addItem: product={0} - CALLED!", product));
-
-               // product should not be null
-               if (null == product) {
-                       // Abort here
-                       throw new NullPointerException("product is null");
-               }
-
-               // Generate item instance
-               AddableBasketItem item = new BasketItem(product, this.getOrderedAmount());
-
-               // Is orderedAmount set?
-               if (this.getOrderedAmount() == null) {
-                       // Trace message
-                       //this.getLogger().logTrace("addItem: orderedAmount not specified, returning null ... - EXIT!");
-
-                       // No orderedAmount specified?!
-                       return null;
-               }
-
-               try {
-                       // item should not be null
-                       if (null == item) {
-                               // Abort here
-                               throw new NullPointerException("item is null"); //NOI18N
-                       }
-
-                       // Deligate to model
-                       this.basket.addItem(item);
-
-                       // Remove orderedAmount
-                       this.setOrderedAmount(null);
-
-                       // Trace message
-                       //this.getLogger().logTrace(MessageFormat.format("addItem: item {0} - has been added to basket. - EXIT!", item));
-                       // Added
-                       return "item_added"; //NOI18N
-               } catch (final BasketItemAlreadyAddedException ex) {
-                       // Throw unchecked exception
-                       throw new FacesException(ex);
-               }
-       }
-
-       @Override
-       public List<AddableBasketItem> allItems () {
-               // Trace message
-               //this.getLogger().logTrace("allItems: CALLED!");
-
-               // Deligate to basket instance
-               List<AddableBasketItem> list = this.basket.getAll();
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("allItems: list={0} - EXIT!", list));
-               // Return it
-               return list;
-       }
-
-       @Override
-       public Float calculateCurrentItemPrice () {
-               // Trace message
-               //this.getLogger().logTrace("calculateCurrentItemPrice: CALLED!");
-
-               // Is the current item/amount set?
-               if (this.getCurrentItem() == null) {
-                       // Current item is null
-                       throw new NullPointerException("currentItem is null"); //NOI18N
-               } else if (this.getCurrentItem().getItemProduct() == null) {
-                       // Product is null
-                       throw new NullPointerException("currentItem.product is null"); //NOI18N
-               } else if (this.getCurrentItem().getOrderedAmount() == null) {
-                       // Amount is null
-                       throw new NullPointerException("currentItem.amount is null"); //NOI18N
-               }
-
-               // Caculate item's price
-               Float totalPrice = (this.getCurrentItem().getItemProduct().getProductPrice() * this.getCurrentItem().getOrderedAmount());
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("calculateCurrentItemPrice: totalPrice={0} - EXIT!", totalPrice));
-               // Return it
-               return totalPrice;
-       }
-
-       @Override
-       public Float calculateItemPrice (final AddableBasketItem item) {
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("calculateItemPrice: item={0} - CALLED!", item));
-
-               // item must not be null
-               if (null == item) {
-                       // Abort here
-                       throw new NullPointerException("item is null");
-               }
-
-               // Default value
-               Float totalPrice = 0.0f;
-
-               // Is it a product?
-               if (item.isProductType()) {
-                       // Caculate item's price
-                       totalPrice = (item.getItemProduct().getProductPrice() * item.getOrderedAmount());
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("calculateItemPrice: totalPrice={0} - EXIT!", totalPrice));
-               // Return it
-               return totalPrice;
-       }
-
-       @Override
-       public Float calculateTotalPrice () {
-               // Trace message
-               //this.getLogger().logTrace("calculateTotalPrice: CALLED!");
-
-               // Init total price
-               Float totalPrice = 0.0f;
-
-               // Iterate over all items
-               for (final AddableBasketItem item : this.allItems()) {
-                       // Is the item a product?
-                       if (item.isProductType()) {
-                               // Calculate single price and add it
-                               totalPrice += this.calculateItemPrice(item);
-                       }
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("calculateTotalPrice: totalPrice={0} - EXIT!", totalPrice));
-               // Return final sum
-               return totalPrice;
-       }
-
-       @Override
-       public String changeItem (final AddableBasketItem item) {
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("changeItem: item={0} - CALLED!", item));
-
-               // item shall not be null
-               if (null == item) {
-                       // Abort here
-                       throw new NullPointerException("item is null");
-               }
-
-               // Default is not found
-               String targetPage = "item_not_changed"; //NOI18N
-
-               // Lookup item in basket
-               for (final AddableBasketItem basketItem : this.allItems()) {
-                       // Is it the same?
-                       if (basketItem.equals(item)) {
-                               // Found it, so allow redirect to proper page
-                               targetPage = "basket"; //NOI18N
-                               break;
-                       }
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("changeItem: targetPage={0} - EXIT!", targetPage));
-               // Return page
-               return targetPage;
-       }
-
-       @Override
-       public void clear () {
-               // @TODO Also clear EJB
-               // Deligate to basket instance
-               this.basket.clear();
-       }
-
-       @Override
-       public AddableBasketItem getCurrentItem () {
-               return this.currentItem;
-       }
-
-       @Override
-       public void setCurrentItem (final AddableBasketItem currentItem) {
-               this.currentItem = currentItem;
-       }
-
-       @Override
-       public Long getItemAmount (final Product product) {
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("getItemAmount: product={0} - CALLED!", product));
-
-               // product should not be null
-               if (null == product) {
-                       // Abort here
-                       throw new NullPointerException("product is null");
-               }
-
-               // Initial value is zero
-               Long itemAmount = 0L;
-
-               // Iterate over all
-               for (final AddableBasketItem item : this.allItems()) {
-                       // Debug message
-                       //this.getLogger().logDebug(MessageFormat.format("getItemAmount: item={0}", item));
-
-                       // Is this product instance and same?
-                       if (null == item) {
-                               // item is null
-                               throw new NullPointerException("item is null");
-                       } else if ((item.isProductType()) && (item.getItemProduct().equals(product))) {
-                               // Found it
-                               itemAmount = item.getOrderedAmount();
-                               break;
-                       }
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("getItemAmount: itemAmount={0} - EXIT!", itemAmount));
-               // Return it
-               return itemAmount;
-       }
-
-       @Override
-       public AddableBasketItem getLast () {
-               // Deligate to basket instance
-               return this.basket.getLast();
-       }
-
-       @Override
-       public int getLastNumRows () {
-               // Deligate to basket instance
-               return this.basket.getLastNumRows();
-       }
-
-       @Override
-       public Long getOrderedAmount () {
-               return this.orderedAmount;
-       }
-
-       @Override
-       public void setOrderedAmount (final Long orderedAmount) {
-               this.orderedAmount = orderedAmount;
-       }
-
-       @Override
-       public boolean hasItems () {
-               // Call above and invert it
-               return (!this.isEmpty());
-       }
-
-       @Override
-       public boolean isEmpty () {
-               // Deligate to basket instance
-               return this.basket.isEmpty();
-       }
-
-       @Override
-       public boolean isProductAdded (final Product product) {
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("isProductAdded: product={0} - EXIT!", product));
-
-               // Must not be null
-               if (null == product) {
-                       // Abort here
-                       throw new NullPointerException("product is null"); //NOI18N
-               }
-
-               // Generate fake instance
-               AddableBasketItem fake = new BasketItem(product);
-
-               // Debug message
-               //this.getLogger().logDebug(MessageFormat.format("isProductAdded: fake={0}", fake));
-               // Ask bean about it
-               boolean isAdded = this.basket.isAdded(fake);
-
-               // Debug message
-               //this.getLogger().logDebug(MessageFormat.format("isProductAdded: isAdded={0}", isAdded));
-               // Is it added?
-               if (isAdded) {
-                       // Get item
-                       AddableBasketItem item = this.getItemFromProduct(product);
-
-                       // Debug message
-                       //this.getLogger().logDebug(MessageFormat.format("isProductAdded: item={0} - setting as current item.", item));
-                       // Set this as current item
-                       this.setCurrentItem(item);
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("isProductAdded: isAdded={0} - EXIT!", isAdded));
-               // Return status
-               return isAdded;
-       }
-
-       @Override
-       public String outputLastAddedItem () {
-               // Trace message
-               //this.getLogger().logTrace("outputLastAddedItem: CALLED!");
-
-               // Default message
-               String lastItem = ""; //NOI18N
-
-               // Get instance
-               AddableBasketItem item = this.getLast();
-
-               // Is it set?
-               if (item instanceof AddableBasketItem) {
-                       // Get type
-                       switch (item.getItemType()) {
-                               case "product": // Sellable product //NOI18N
-                                       assert (item.getItemProduct() instanceof Product) : MessageFormat.format("item {0} has no product instance set.", item); //NOI18N
-
-                                       // Get title
-                                       lastItem = item.getItemProduct().getProductTitle();
-                                       break;
-
-                               default: // Not supported
-                                       throw new FacesException(MessageFormat.format("item type {0} is not supported.", item.getItemType())); //NOI18N
-                       }
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("outputLastAddedItem: lastItem={0} - EXIT!", lastItem));
-               // Return it
-               return lastItem;
-       }
-
-       /**
-        * Getter for basket bean instance
-        * <p>
-        * @return Basket bean instance
-        */
-       private BasketSessionBeanRemote getBasketBean () {
-               return this.basketBean;
-       }
-
-       /**
-        * Somewhat getter for an item instance from given product instance. This
-        * method returns null if no item was found to given product. The product is
-        * found by checking it's id and itemType=product
-        * <p>
-        * @param product Product instance
-        * <p>
-        * @return Item instance or null if not found
-        */
-       private AddableBasketItem getItemFromProduct (final Product product) {
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("getItemFromProduct: product={0} - CALLED!", product));
-
-               // Product must not be null
-               if (null == product) {
-                       // Abort here
-                       throw new NullPointerException("product is null"); //NOI18N
-               }
-
-               // Create item instance
-               AddableBasketItem foundItem = null;
-
-               // Create fake instance
-               AddableBasketItem fake = new BasketItem(product);
-
-               // Debug message
-               //this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: fake={0}", fake));
-               // Get all items
-               List<AddableBasketItem> list = this.basket.getAll();
-
-               // Debug message
-               //this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: list={0}", list));
-               // Check all entries
-               for (final AddableBasketItem item : list) {
-                       // Debug message
-                       //this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: item={0}", item));
-
-                       // item must not be null
-                       if (null == item) {
-                               // Abort here
-                               throw new NullPointerException("item is null"); //NOI18N
-                       }
-
-                       // Is it the same?
-                       if (item.equals(fake)) {
-                               // Set found item and abort look
-                               foundItem = item;
-                               break;
-                       }
-               }
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("getItemFromProduct: foundItem={0} - EXIT!", foundItem));
-               // Return it
-               return foundItem;
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java
deleted file mode 100644 (file)
index 04b3cd6..0000000
+++ /dev/null
@@ -1,170 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.basket;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jshopcore.model.basket.AddableBasketItem;
-import org.mxchange.jshopcore.model.product.Product;
-
-/**
- * An interface for a basket
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface BasketWebController extends Serializable {
-
-       /**
-        * Adds given product instance to basket by adding amount from form data to
-        * it.
-        * <p>
-        * @param product Product instance to add
-        * <p>
-        * @return Redirect target or null
-        */
-       String addItem (final Product product);
-
-       /**
-        * Gets for all added items
-        * <p>
-        * @return A list of all added items
-        */
-       List<AddableBasketItem> allItems ();
-
-       /**
-        * Calculates total price (no tax added) of current item. If no current item
-        * is set and no amount, a NPE is thrown.
-        * <p>
-        * @return Current item's total price
-        */
-       Float calculateCurrentItemPrice ();
-
-       /**
-        * Calculates total price (no tax added) for given item.
-        * <p>
-        * @param item Item instance to calculate total price for
-        * <p>
-        * @return Total price
-        */
-       Float calculateItemPrice (final AddableBasketItem item);
-
-       /**
-        * Calculates total sum (no tax added) for all items
-        * <p>
-        * @return Total price of all items
-        */
-       Float calculateTotalPrice ();
-
-       /**
-        * Changes given item instance's amount in basket and redirects to proper
-        * page. If the item is not found, another "error" page is called.
-        * <p>
-        * @param item Item instance to change
-        * <p>
-        * @return Page redirection
-        */
-       String changeItem (final AddableBasketItem item);
-
-       /**
-        * Clears this basket instance
-        */
-       void clear ();
-
-       /**
-        * Getter for item amount property
-        * <p>
-        * @return Item amount property
-        */
-       Long getOrderedAmount ();
-
-       /**
-        * Setter for item amount property
-        * <p>
-        * @param amount Item amount property
-        */
-       void setOrderedAmount (final Long amount);
-
-       /**
-        * Getter for current item
-        * <p>
-        * @return Current item
-        */
-       AddableBasketItem getCurrentItem ();
-
-       /**
-        * Setter for current item
-        * <p>
-        * @param currentItem Current item
-        */
-       void setCurrentItem (final AddableBasketItem currentItem);
-
-       /**
-        * Some getter for item amount of given product. This method requires a full
-        * iteration over all items in the basket to look for proper product
-        * instance.
-        * <p>
-        * @param product Product instance
-        * <p>
-        * @return Item amount of given product
-        */
-       Long getItemAmount (final Product product);
-
-       /**
-        * Getter for last entry
-        * <p>
-        * @return Last added item in basket
-        */
-       AddableBasketItem getLast ();
-
-       /**
-        * Getter for last num rows
-        * <p>
-        * @return Last num rows
-        */
-       int getLastNumRows ();
-
-       /**
-        * Checks whether the basket has items in it. This method is wrapper to
-        * isEmpty()
-        * <p>
-        * @return Whether the basket is empty
-        */
-       boolean hasItems ();
-
-       /**
-        * Checks whether the basket is empty
-        * <p>
-        * @return Whether the basket is empty
-        */
-       boolean isEmpty ();
-
-       /**
-        * Checks whether the currently set product is added in basked
-        * <p>
-        * @param product Product instance
-        * <p>
-        * @return Whether the product is added
-        */
-       boolean isProductAdded (final Product product);
-
-       /**
-        * Outputs last added item in the basket.
-        * <p>
-        * @return Last added item
-        */
-       String outputLastAddedItem ();
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebSessionBean.java
new file mode 100644 (file)
index 0000000..5b10a76
--- /dev/null
@@ -0,0 +1,479 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.basket;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException;
+import org.mxchange.jshopcore.model.basket.AddableBasketItem;
+import org.mxchange.jshopcore.model.basket.Basket;
+import org.mxchange.jshopcore.model.basket.BasketSessionBeanRemote;
+import org.mxchange.jshopcore.model.basket.ShopBasket;
+import org.mxchange.jshopcore.model.basket.items.BasketItem;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * A bean for the basket
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("basketController")
+@SessionScoped
+public class BasketWebSessionBean implements BasketWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_476_347_320_198L;
+
+       /**
+        * Instance of wrapped basket
+        */
+       private final Basket<AddableBasketItem> basket;
+
+       /**
+        * Basket bean
+        */
+       private final BasketSessionBeanRemote basketBean;
+
+
+       /**
+        * Current item
+        */
+       private AddableBasketItem currentItem;
+
+       /////////////////////// Properties /////////////////////
+       /**
+        * Ordered orderedAmount
+        */
+       private Long orderedAmount;
+
+       /**
+        * Default constructor
+        */
+       public BasketWebSessionBean () {
+               // Get new application instance
+               this.basket = new ShopBasket();
+
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.basketBean = (BasketSessionBeanRemote) context.lookup("ejb/stateless-basket"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public String addItem (final Product product) {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("addItem: product={0} - CALLED!", product));
+
+               // product should not be null
+               if (null == product) {
+                       // Abort here
+                       throw new NullPointerException("product is null");
+               }
+
+               // Generate item instance
+               AddableBasketItem item = new BasketItem(product, this.getOrderedAmount());
+
+               // Is orderedAmount set?
+               if (this.getOrderedAmount() == null) {
+                       // Trace message
+                       //this.getLogger().logTrace("addItem: orderedAmount not specified, returning null ... - EXIT!");
+
+                       // No orderedAmount specified?!
+                       return null;
+               }
+
+               try {
+                       // item should not be null
+                       if (null == item) {
+                               // Abort here
+                               throw new NullPointerException("item is null"); //NOI18N
+                       }
+
+                       // Deligate to model
+                       this.basket.addItem(item);
+
+                       // Remove orderedAmount
+                       this.setOrderedAmount(null);
+
+                       // Trace message
+                       //this.getLogger().logTrace(MessageFormat.format("addItem: item {0} - has been added to basket. - EXIT!", item));
+                       // Added
+                       return "item_added"; //NOI18N
+               } catch (final BasketItemAlreadyAddedException ex) {
+                       // Throw unchecked exception
+                       throw new FacesException(ex);
+               }
+       }
+
+       @Override
+       public List<AddableBasketItem> allItems () {
+               // Trace message
+               //this.getLogger().logTrace("allItems: CALLED!");
+
+               // Deligate to basket instance
+               List<AddableBasketItem> list = this.basket.getAll();
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("allItems: list={0} - EXIT!", list));
+               // Return it
+               return list;
+       }
+
+       @Override
+       public Float calculateCurrentItemPrice () {
+               // Trace message
+               //this.getLogger().logTrace("calculateCurrentItemPrice: CALLED!");
+
+               // Is the current item/amount set?
+               if (this.getCurrentItem() == null) {
+                       // Current item is null
+                       throw new NullPointerException("currentItem is null"); //NOI18N
+               } else if (this.getCurrentItem().getItemProduct() == null) {
+                       // Product is null
+                       throw new NullPointerException("currentItem.product is null"); //NOI18N
+               } else if (this.getCurrentItem().getOrderedAmount() == null) {
+                       // Amount is null
+                       throw new NullPointerException("currentItem.amount is null"); //NOI18N
+               }
+
+               // Caculate item's price
+               Float totalPrice = (this.getCurrentItem().getItemProduct().getProductPrice() * this.getCurrentItem().getOrderedAmount());
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("calculateCurrentItemPrice: totalPrice={0} - EXIT!", totalPrice));
+               // Return it
+               return totalPrice;
+       }
+
+       @Override
+       public Float calculateItemPrice (final AddableBasketItem item) {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("calculateItemPrice: item={0} - CALLED!", item));
+
+               // item must not be null
+               if (null == item) {
+                       // Abort here
+                       throw new NullPointerException("item is null");
+               }
+
+               // Default value
+               Float totalPrice = 0.0f;
+
+               // Is it a product?
+               if (item.isProductType()) {
+                       // Caculate item's price
+                       totalPrice = (item.getItemProduct().getProductPrice() * item.getOrderedAmount());
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("calculateItemPrice: totalPrice={0} - EXIT!", totalPrice));
+               // Return it
+               return totalPrice;
+       }
+
+       @Override
+       public Float calculateTotalPrice () {
+               // Trace message
+               //this.getLogger().logTrace("calculateTotalPrice: CALLED!");
+
+               // Init total price
+               Float totalPrice = 0.0f;
+
+               // Iterate over all items
+               for (final AddableBasketItem item : this.allItems()) {
+                       // Is the item a product?
+                       if (item.isProductType()) {
+                               // Calculate single price and add it
+                               totalPrice += this.calculateItemPrice(item);
+                       }
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("calculateTotalPrice: totalPrice={0} - EXIT!", totalPrice));
+               // Return final sum
+               return totalPrice;
+       }
+
+       @Override
+       public String changeItem (final AddableBasketItem item) {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("changeItem: item={0} - CALLED!", item));
+
+               // item shall not be null
+               if (null == item) {
+                       // Abort here
+                       throw new NullPointerException("item is null");
+               }
+
+               // Default is not found
+               String targetPage = "item_not_changed"; //NOI18N
+
+               // Lookup item in basket
+               for (final AddableBasketItem basketItem : this.allItems()) {
+                       // Is it the same?
+                       if (basketItem.equals(item)) {
+                               // Found it, so allow redirect to proper page
+                               targetPage = "basket"; //NOI18N
+                               break;
+                       }
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("changeItem: targetPage={0} - EXIT!", targetPage));
+               // Return page
+               return targetPage;
+       }
+
+       @Override
+       public void clear () {
+               // @TODO Also clear EJB
+               // Deligate to basket instance
+               this.basket.clear();
+       }
+
+       @Override
+       public AddableBasketItem getCurrentItem () {
+               return this.currentItem;
+       }
+
+       @Override
+       public void setCurrentItem (final AddableBasketItem currentItem) {
+               this.currentItem = currentItem;
+       }
+
+       @Override
+       public Long getItemAmount (final Product product) {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("getItemAmount: product={0} - CALLED!", product));
+
+               // product should not be null
+               if (null == product) {
+                       // Abort here
+                       throw new NullPointerException("product is null");
+               }
+
+               // Initial value is zero
+               Long itemAmount = 0L;
+
+               // Iterate over all
+               for (final AddableBasketItem item : this.allItems()) {
+                       // Debug message
+                       //this.getLogger().logDebug(MessageFormat.format("getItemAmount: item={0}", item));
+
+                       // Is this product instance and same?
+                       if (null == item) {
+                               // item is null
+                               throw new NullPointerException("item is null");
+                       } else if ((item.isProductType()) && (item.getItemProduct().equals(product))) {
+                               // Found it
+                               itemAmount = item.getOrderedAmount();
+                               break;
+                       }
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("getItemAmount: itemAmount={0} - EXIT!", itemAmount));
+               // Return it
+               return itemAmount;
+       }
+
+       @Override
+       public AddableBasketItem getLast () {
+               // Deligate to basket instance
+               return this.basket.getLast();
+       }
+
+       @Override
+       public int getLastNumRows () {
+               // Deligate to basket instance
+               return this.basket.getLastNumRows();
+       }
+
+       @Override
+       public Long getOrderedAmount () {
+               return this.orderedAmount;
+       }
+
+       @Override
+       public void setOrderedAmount (final Long orderedAmount) {
+               this.orderedAmount = orderedAmount;
+       }
+
+       @Override
+       public boolean hasItems () {
+               // Call above and invert it
+               return (!this.isEmpty());
+       }
+
+       @Override
+       public boolean isEmpty () {
+               // Deligate to basket instance
+               return this.basket.isEmpty();
+       }
+
+       @Override
+       public boolean isProductAdded (final Product product) {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("isProductAdded: product={0} - EXIT!", product));
+
+               // Must not be null
+               if (null == product) {
+                       // Abort here
+                       throw new NullPointerException("product is null"); //NOI18N
+               }
+
+               // Generate fake instance
+               AddableBasketItem fake = new BasketItem(product);
+
+               // Debug message
+               //this.getLogger().logDebug(MessageFormat.format("isProductAdded: fake={0}", fake));
+               // Ask bean about it
+               boolean isAdded = this.basket.isAdded(fake);
+
+               // Debug message
+               //this.getLogger().logDebug(MessageFormat.format("isProductAdded: isAdded={0}", isAdded));
+               // Is it added?
+               if (isAdded) {
+                       // Get item
+                       AddableBasketItem item = this.getItemFromProduct(product);
+
+                       // Debug message
+                       //this.getLogger().logDebug(MessageFormat.format("isProductAdded: item={0} - setting as current item.", item));
+                       // Set this as current item
+                       this.setCurrentItem(item);
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("isProductAdded: isAdded={0} - EXIT!", isAdded));
+               // Return status
+               return isAdded;
+       }
+
+       @Override
+       public String outputLastAddedItem () {
+               // Trace message
+               //this.getLogger().logTrace("outputLastAddedItem: CALLED!");
+
+               // Default message
+               String lastItem = ""; //NOI18N
+
+               // Get instance
+               AddableBasketItem item = this.getLast();
+
+               // Is it set?
+               if (item instanceof AddableBasketItem) {
+                       // Get type
+                       switch (item.getItemType()) {
+                               case "product": // Sellable product //NOI18N
+                                       assert (item.getItemProduct() instanceof Product) : MessageFormat.format("item {0} has no product instance set.", item); //NOI18N
+
+                                       // Get title
+                                       lastItem = item.getItemProduct().getProductTitle();
+                                       break;
+
+                               default: // Not supported
+                                       throw new FacesException(MessageFormat.format("item type {0} is not supported.", item.getItemType())); //NOI18N
+                       }
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("outputLastAddedItem: lastItem={0} - EXIT!", lastItem));
+               // Return it
+               return lastItem;
+       }
+
+       /**
+        * Getter for basket bean instance
+        * <p>
+        * @return Basket bean instance
+        */
+       private BasketSessionBeanRemote getBasketBean () {
+               return this.basketBean;
+       }
+
+       /**
+        * Somewhat getter for an item instance from given product instance. This
+        * method returns null if no item was found to given product. The product is
+        * found by checking it's id and itemType=product
+        * <p>
+        * @param product Product instance
+        * <p>
+        * @return Item instance or null if not found
+        */
+       private AddableBasketItem getItemFromProduct (final Product product) {
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("getItemFromProduct: product={0} - CALLED!", product));
+
+               // Product must not be null
+               if (null == product) {
+                       // Abort here
+                       throw new NullPointerException("product is null"); //NOI18N
+               }
+
+               // Create item instance
+               AddableBasketItem foundItem = null;
+
+               // Create fake instance
+               AddableBasketItem fake = new BasketItem(product);
+
+               // Debug message
+               //this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: fake={0}", fake));
+               // Get all items
+               List<AddableBasketItem> list = this.basket.getAll();
+
+               // Debug message
+               //this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: list={0}", list));
+               // Check all entries
+               for (final AddableBasketItem item : list) {
+                       // Debug message
+                       //this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: item={0}", item));
+
+                       // item must not be null
+                       if (null == item) {
+                               // Abort here
+                               throw new NullPointerException("item is null"); //NOI18N
+                       }
+
+                       // Is it the same?
+                       if (item.equals(fake)) {
+                               // Set found item and abort look
+                               foundItem = item;
+                               break;
+                       }
+               }
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("getItemFromProduct: foundItem={0} - EXIT!", foundItem));
+               // Return it
+               return foundItem;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebSessionController.java
new file mode 100644 (file)
index 0000000..a2fd6fe
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.basket;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jshopcore.model.basket.AddableBasketItem;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * An interface for a basket
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface BasketWebSessionController extends Serializable {
+
+       /**
+        * Adds given product instance to basket by adding amount from form data to
+        * it.
+        * <p>
+        * @param product Product instance to add
+        * <p>
+        * @return Redirect target or null
+        */
+       String addItem (final Product product);
+
+       /**
+        * Gets for all added items
+        * <p>
+        * @return A list of all added items
+        */
+       List<AddableBasketItem> allItems ();
+
+       /**
+        * Calculates total price (no tax added) of current item. If no current item
+        * is set and no amount, a NPE is thrown.
+        * <p>
+        * @return Current item's total price
+        */
+       Float calculateCurrentItemPrice ();
+
+       /**
+        * Calculates total price (no tax added) for given item.
+        * <p>
+        * @param item Item instance to calculate total price for
+        * <p>
+        * @return Total price
+        */
+       Float calculateItemPrice (final AddableBasketItem item);
+
+       /**
+        * Calculates total sum (no tax added) for all items
+        * <p>
+        * @return Total price of all items
+        */
+       Float calculateTotalPrice ();
+
+       /**
+        * Changes given item instance's amount in basket and redirects to proper
+        * page. If the item is not found, another "error" page is called.
+        * <p>
+        * @param item Item instance to change
+        * <p>
+        * @return Page redirection
+        */
+       String changeItem (final AddableBasketItem item);
+
+       /**
+        * Clears this basket instance
+        */
+       void clear ();
+
+       /**
+        * Getter for item amount property
+        * <p>
+        * @return Item amount property
+        */
+       Long getOrderedAmount ();
+
+       /**
+        * Setter for item amount property
+        * <p>
+        * @param amount Item amount property
+        */
+       void setOrderedAmount (final Long amount);
+
+       /**
+        * Getter for current item
+        * <p>
+        * @return Current item
+        */
+       AddableBasketItem getCurrentItem ();
+
+       /**
+        * Setter for current item
+        * <p>
+        * @param currentItem Current item
+        */
+       void setCurrentItem (final AddableBasketItem currentItem);
+
+       /**
+        * Some getter for item amount of given product. This method requires a full
+        * iteration over all items in the basket to look for proper product
+        * instance.
+        * <p>
+        * @param product Product instance
+        * <p>
+        * @return Item amount of given product
+        */
+       Long getItemAmount (final Product product);
+
+       /**
+        * Getter for last entry
+        * <p>
+        * @return Last added item in basket
+        */
+       AddableBasketItem getLast ();
+
+       /**
+        * Getter for last num rows
+        * <p>
+        * @return Last num rows
+        */
+       int getLastNumRows ();
+
+       /**
+        * Checks whether the basket has items in it. This method is wrapper to
+        * isEmpty()
+        * <p>
+        * @return Whether the basket is empty
+        */
+       boolean hasItems ();
+
+       /**
+        * Checks whether the basket is empty
+        * <p>
+        * @return Whether the basket is empty
+        */
+       boolean isEmpty ();
+
+       /**
+        * Checks whether the currently set product is added in basked
+        * <p>
+        * @param product Product instance
+        * <p>
+        * @return Whether the product is added
+        */
+       boolean isProductAdded (final Product product);
+
+       /**
+        * Outputs last added item in the basket.
+        * <p>
+        * @return Last added item
+        */
+       String outputLastAddedItem ();
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java
deleted file mode 100644 (file)
index 33ceaca..0000000
+++ /dev/null
@@ -1,130 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.category;
-
-import javax.enterprise.context.RequestScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.exceptions.CannotAddCategoryException;
-import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
-import org.mxchange.jshopcore.model.category.AdminCategorySessionBeanRemote;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.category.ProductCategory;
-import org.mxchange.pizzaapplication.beans.shop.ShopWebController;
-
-/**
- * Main application class
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("admin_category")
-@RequestScoped
-public class AdminCategoryWebBean implements AdminCategoryWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 5_819_375_183_472_871L;
-
-       /**
-        * Remote bean for categories
-        */
-       private AdminCategorySessionBeanRemote categoryBean;
-
-       /////////////////////// Properties /////////////////////
-       /**
-        * Category categoryTitle
-        */
-       private String categoryTitle;
-
-       /**
-        * Parent category
-        */
-       private Category parentCategory;
-
-       ////////////////////// Bean injections ///////////////////////
-
-       /**
-        * Shop bean
-        */
-       @Inject
-       private ShopWebController shopController;
-
-       /**
-        * Default constructor
-        */
-       public AdminCategoryWebBean () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       this.categoryBean = (AdminCategorySessionBeanRemote) context.lookup("ejb/stateless-admin-category"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw it again
-                       throw new FaceletException(e);
-               }
-       }
-
-       @Override
-       public void addCategory () throws FaceletException {
-               try {
-                       // Create category
-                       Category category = new ProductCategory();
-                       category.setParentCategory(this.getParentCategory());
-                       category.setCategoryTitle(this.getCategoryTitle());
-
-                       // Deligate to remote bean
-                       Category updatedCategory = this.categoryBean.doAdminAddCategory(category);
-
-                       // Also send it to the controller bean
-                       this.shopController.addCategory(updatedCategory);
-
-                       // Unset all older values
-                       this.setCategoryTitle(""); //NOI18N
-                       this.setParentCategory(null);
-               } catch (final CategoryTitleAlreadyUsedException | CannotAddCategoryException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public String getCategoryTitle () {
-               return this.categoryTitle;
-       }
-
-       @Override
-       public void setCategoryTitle (final String categoryTitle) {
-               this.categoryTitle = categoryTitle;
-       }
-
-       @Override
-       public Category getParentCategory () {
-               return this.parentCategory;
-       }
-
-       @Override
-       public void setParentCategory (final Category parentCategory) {
-               this.parentCategory = parentCategory;
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebController.java
deleted file mode 100644 (file)
index 4cef66d..0000000
+++ /dev/null
@@ -1,64 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.category;
-
-import javax.faces.view.facelets.FaceletException;
-import org.mxchange.jshopcore.model.category.Category;
-
-/**
- * An interface for product controllers for "ADMIN" role
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface AdminCategoryWebController {
-
-       /**
-        * Adds given category data from request to database
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If something
-        * unexpected happened
-        */
-       void addCategory () throws FaceletException;
-
-       /**
-        * Getter for parent id
-        * <p>
-        * @return Parent id
-        */
-       Category getParentCategory ();
-
-       /**
-        * Setter for parent category
-        * <p>
-        * @param parentCategory Parent category to set
-        */
-       void setParentCategory (final Category parentCategory);
-
-       /**
-        * Getter for category title
-        * <p>
-        * @return the title
-        */
-       String getCategoryTitle ();
-
-       /**
-        * Setter for category title
-        * <p>
-        * @param categoryTitle the title to set
-        */
-       void setCategoryTitle (final String categoryTitle);
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebRequestBean.java
new file mode 100644 (file)
index 0000000..6e18de4
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.category;
+
+import javax.enterprise.context.RequestScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.exceptions.CannotAddCategoryException;
+import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
+import org.mxchange.jshopcore.model.category.AdminCategorySessionBeanRemote;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.category.ProductCategory;
+import org.mxchange.pizzaapplication.beans.shop.ShopWebApplicationController;
+
+/**
+ * Main application class
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("admin_category")
+@RequestScoped
+public class AdminCategoryWebRequestBean implements AdminCategoryWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_819_375_183_472_871L;
+
+       /**
+        * Remote bean for categories
+        */
+       private AdminCategorySessionBeanRemote categoryBean;
+
+       /////////////////////// Properties /////////////////////
+       /**
+        * Category categoryTitle
+        */
+       private String categoryTitle;
+
+       /**
+        * Parent category
+        */
+       private Category parentCategory;
+
+       ////////////////////// Bean injections ///////////////////////
+
+       /**
+        * Shop bean
+        */
+       @Inject
+       private ShopWebApplicationController shopController;
+
+       /**
+        * Default constructor
+        */
+       public AdminCategoryWebRequestBean () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the bean
+                       this.categoryBean = (AdminCategorySessionBeanRemote) context.lookup("ejb/stateless-admin-category"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw it again
+                       throw new FaceletException(e);
+               }
+       }
+
+       @Override
+       public void addCategory () throws FaceletException {
+               try {
+                       // Create category
+                       Category category = new ProductCategory();
+                       category.setParentCategory(this.getParentCategory());
+                       category.setCategoryTitle(this.getCategoryTitle());
+
+                       // Deligate to remote bean
+                       Category updatedCategory = this.categoryBean.doAdminAddCategory(category);
+
+                       // Also send it to the controller bean
+                       this.shopController.addCategory(updatedCategory);
+
+                       // Unset all older values
+                       this.setCategoryTitle(""); //NOI18N
+                       this.setParentCategory(null);
+               } catch (final CategoryTitleAlreadyUsedException | CannotAddCategoryException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public String getCategoryTitle () {
+               return this.categoryTitle;
+       }
+
+       @Override
+       public void setCategoryTitle (final String categoryTitle) {
+               this.categoryTitle = categoryTitle;
+       }
+
+       @Override
+       public Category getParentCategory () {
+               return this.parentCategory;
+       }
+
+       @Override
+       public void setParentCategory (final Category parentCategory) {
+               this.parentCategory = parentCategory;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebRequestController.java
new file mode 100644 (file)
index 0000000..8cdc11a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.category;
+
+import javax.faces.view.facelets.FaceletException;
+import org.mxchange.jshopcore.model.category.Category;
+
+/**
+ * An interface for product controllers for "ADMIN" role
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminCategoryWebRequestController {
+
+       /**
+        * Adds given category data from request to database
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If something
+        * unexpected happened
+        */
+       void addCategory () throws FaceletException;
+
+       /**
+        * Getter for parent id
+        * <p>
+        * @return Parent id
+        */
+       Category getParentCategory ();
+
+       /**
+        * Setter for parent category
+        * <p>
+        * @param parentCategory Parent category to set
+        */
+       void setParentCategory (final Category parentCategory);
+
+       /**
+        * Getter for category title
+        * <p>
+        * @return the title
+        */
+       String getCategoryTitle ();
+
+       /**
+        * Setter for category title
+        * <p>
+        * @param categoryTitle the title to set
+        */
+       void setCategoryTitle (final String categoryTitle);
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java
deleted file mode 100644 (file)
index 95b1bf6..0000000
+++ /dev/null
@@ -1,230 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.checkout;
-
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.SessionScoped;
-import javax.faces.FacesException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.model.basket.AddableBasketItem;
-import org.mxchange.jshopcore.model.customer.Customer;
-import org.mxchange.jshopcore.wrapper.CheckoutWrapper;
-import org.mxchange.jshopcore.wrapper.WrapableCheckout;
-import org.mxchange.pizzaapplication.beans.basket.BasketWebController;
-import org.mxchange.pizzaapplication.beans.customer.CustomerWebController;
-import org.mxchange.pizzaapplication.beans.receipt.ReceiptWebController;
-
-/**
- * Checkout controller
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("checkoutController")
-@SessionScoped
-public class CheckoutWebBean implements CheckoutWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 51_987_348_347_183L;
-
-       ////////////////////// Bean injections ///////////////////////
-       /**
-        * Basket bean
-        */
-       @Inject
-       private BasketWebController basketController;
-
-       /**
-        * Connection
-        */
-       private Connection connection;
-
-       /**
-        * Customer instance
-        */
-       private Customer customer;
-
-       /**
-        * Customer bean
-        */
-       @Inject
-       private CustomerWebController customerController;
-
-       /**
-        * Object message
-        */
-       private ObjectMessage message;
-
-       /**
-        * Message producer
-        */
-       private MessageProducer messageProducer;
-
-       /**
-        * Queue instance
-        */
-       private Queue queue;
-
-       /**
-        * Receipt bean
-        */
-       @Inject
-       private ReceiptWebController receiptController;
-
-       /**
-        * Session instance
-        */
-       private Session session;
-
-       /**
-        * Destructor
-        */
-       @PreDestroy
-       public void destroy () {
-               try {
-                       // Try to close all
-                       this.messageProducer.close();
-                       this.session.close();
-                       this.connection.close();
-               } catch (final JMSException ex) {
-                       // TODO: Continue to throw is fine?
-                       throw new FacesException(ex);
-               }
-       }
-
-       @Override
-       public String doCheckout () {
-               // Trace message
-               //this.getLogger().logTrace("doCheckout: CALLED!");
-
-               // Are the beans set?
-               if (null == this.basketController) {
-                       // Abort here
-                       throw new NullPointerException("basketController is null"); //NOI18N
-               } else if (null == this.customerController) {
-                       // Abort here
-                       throw new NullPointerException("customer is null"); //NOI18N
-               }
-
-               // Are at least the required fields set?
-               if (!this.customerController.isRequiredPersonalDataSet()) {
-                       // Trace message
-                       //this.getLogger().logTrace("doCheckout: Not all required fields are set, returning checkout2 ... - EXIT!");
-
-                       // Not set, should not happen
-                       return "checkout2"; //NOI18N
-               } else if (this.basketController.isEmpty()) {
-                       // Trace message
-                       //this.getLogger().logTrace("doCheckout: basket is empty, returning empty_basket ... - EXIT!");
-
-                       // Nothing to order
-                       return "empty_basket"; //NOI18N
-               }
-
-               // Create customer instance
-               this.setCustomer(this.customerController.createCustomerInstance());
-
-               // Debug message
-               //this.getLogger().logDebug(MessageFormat.format("doCheckout: customer={0}", this.getCustomer()));
-               // Get ordered list
-               List<AddableBasketItem> list = this.basketController.allItems();
-
-               // Debug message
-               //this.getLogger().logTrace(MessageFormat.format("doCheckout: list={0}", list));
-               // Construct container
-               WrapableCheckout wrapper = new CheckoutWrapper();
-               wrapper.setCustomer(this.getCustomer());
-               wrapper.setList(list);
-
-               try {
-                       // Construct object message
-                       this.message.setObject(wrapper);
-
-                       // Send message
-                       this.messageProducer.send(this.message);
-               } catch (final JMSException ex) {
-                       // TODO: Log exception?
-                       // Not working
-                       return "jms_failed"; //NOI18N
-               }
-
-               // Clear basket
-               this.basketController.clear();
-
-               // Set customer in receipt controller for verification
-               this.receiptController.setCustomer(this.getCustomer());
-
-               // All fine
-               return "checkout_done"; //NOI18N
-       }
-
-       @Override
-       public Customer getCustomer () {
-               return this.customer;
-       }
-
-       @Override
-       public void setCustomer (final Customer customer) {
-               this.customer = customer;
-       }
-
-       /**
-        * Initialization of this bean
-        */
-       @PostConstruct
-       public void init () {
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Get factory from JMS resource
-                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/shopConnectionFactory"); //NOI18N
-
-                       // Lookup queue
-                       this.queue = (Queue) context.lookup("jms/shopCheckoutQueue"); //NOI18N
-
-                       // Create connection
-                       this.connection = connectionFactory.createConnection();
-
-                       // Init session instance
-                       this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-                       // And message producer
-                       this.messageProducer = this.session.createProducer(this.queue);
-
-                       // Finally the message instance itself
-                       this.message = this.session.createObjectMessage();
-               } catch (final NamingException | JMSException e) {
-                       // Continued to throw
-                       throw new FacesException(e);
-               }
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebController.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebController.java
deleted file mode 100644 (file)
index 513ed54..0000000
+++ /dev/null
@@ -1,49 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.checkout;
-
-import java.io.Serializable;
-import org.mxchange.jshopcore.model.customer.Customer;
-
-/**
- * An interface for the shop
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface CheckoutWebController extends Serializable {
-
-       /**
-        * Runs the actual checkout and returns a proper page redirection target.
-        * <p>
-        * @return Page redirection target
-        */
-       String doCheckout ();
-
-       /**
-        * Getter for customer instance
-        * <p>
-        * @return Customer instance
-        */
-       Customer getCustomer ();
-
-       /**
-        * Setter for customer instance
-        * <p>
-        * @param customer Customer instance
-        */
-       void setCustomer (final Customer customer);
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebSessionBean.java
new file mode 100644 (file)
index 0000000..65fb305
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.checkout;
+
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.FacesException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.model.basket.AddableBasketItem;
+import org.mxchange.jshopcore.model.customer.Customer;
+import org.mxchange.jshopcore.wrapper.CheckoutWrapper;
+import org.mxchange.jshopcore.wrapper.WrapableCheckout;
+import org.mxchange.pizzaapplication.beans.basket.BasketWebSessionController;
+import org.mxchange.pizzaapplication.beans.customer.CustomerWebSessionController;
+import org.mxchange.pizzaapplication.beans.receipt.ReceiptWebSessionController;
+
+/**
+ * Checkout controller
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("checkoutController")
+@SessionScoped
+public class CheckoutWebSessionBean implements CheckoutWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 51_987_348_347_183L;
+
+       ////////////////////// Bean injections ///////////////////////
+       /**
+        * Basket bean
+        */
+       @Inject
+       private BasketWebSessionController basketController;
+
+       /**
+        * Connection
+        */
+       private Connection connection;
+
+       /**
+        * Customer instance
+        */
+       private Customer customer;
+
+       /**
+        * Customer bean
+        */
+       @Inject
+       private CustomerWebSessionController customerController;
+
+       /**
+        * Object message
+        */
+       private ObjectMessage message;
+
+       /**
+        * Message producer
+        */
+       private MessageProducer messageProducer;
+
+       /**
+        * Queue instance
+        */
+       private Queue queue;
+
+       /**
+        * Receipt bean
+        */
+       @Inject
+       private ReceiptWebSessionController receiptController;
+
+       /**
+        * Session instance
+        */
+       private Session session;
+
+       /**
+        * Destructor
+        */
+       @PreDestroy
+       public void destroy () {
+               try {
+                       // Try to close all
+                       this.messageProducer.close();
+                       this.session.close();
+                       this.connection.close();
+               } catch (final JMSException ex) {
+                       // TODO: Continue to throw is fine?
+                       throw new FacesException(ex);
+               }
+       }
+
+       @Override
+       public String doCheckout () {
+               // Trace message
+               //this.getLogger().logTrace("doCheckout: CALLED!");
+
+               // Are the beans set?
+               if (null == this.basketController) {
+                       // Abort here
+                       throw new NullPointerException("basketController is null"); //NOI18N
+               } else if (null == this.customerController) {
+                       // Abort here
+                       throw new NullPointerException("customer is null"); //NOI18N
+               }
+
+               // Are at least the required fields set?
+               if (!this.customerController.isRequiredPersonalDataSet()) {
+                       // Trace message
+                       //this.getLogger().logTrace("doCheckout: Not all required fields are set, returning checkout2 ... - EXIT!");
+
+                       // Not set, should not happen
+                       return "checkout2"; //NOI18N
+               } else if (this.basketController.isEmpty()) {
+                       // Trace message
+                       //this.getLogger().logTrace("doCheckout: basket is empty, returning empty_basket ... - EXIT!");
+
+                       // Nothing to order
+                       return "empty_basket"; //NOI18N
+               }
+
+               // Create customer instance
+               this.setCustomer(this.customerController.createCustomerInstance());
+
+               // Debug message
+               //this.getLogger().logDebug(MessageFormat.format("doCheckout: customer={0}", this.getCustomer()));
+               // Get ordered list
+               List<AddableBasketItem> list = this.basketController.allItems();
+
+               // Debug message
+               //this.getLogger().logTrace(MessageFormat.format("doCheckout: list={0}", list));
+               // Construct container
+               WrapableCheckout wrapper = new CheckoutWrapper();
+               wrapper.setCustomer(this.getCustomer());
+               wrapper.setList(list);
+
+               try {
+                       // Construct object message
+                       this.message.setObject(wrapper);
+
+                       // Send message
+                       this.messageProducer.send(this.message);
+               } catch (final JMSException ex) {
+                       // TODO: Log exception?
+                       // Not working
+                       return "jms_failed"; //NOI18N
+               }
+
+               // Clear basket
+               this.basketController.clear();
+
+               // Set customer in receipt controller for verification
+               this.receiptController.setCustomer(this.getCustomer());
+
+               // All fine
+               return "checkout_done"; //NOI18N
+       }
+
+       @Override
+       public Customer getCustomer () {
+               return this.customer;
+       }
+
+       @Override
+       public void setCustomer (final Customer customer) {
+               this.customer = customer;
+       }
+
+       /**
+        * Initialization of this bean
+        */
+       @PostConstruct
+       public void init () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Get factory from JMS resource
+                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/shopConnectionFactory"); //NOI18N
+
+                       // Lookup queue
+                       this.queue = (Queue) context.lookup("jms/shopCheckoutQueue"); //NOI18N
+
+                       // Create connection
+                       this.connection = connectionFactory.createConnection();
+
+                       // Init session instance
+                       this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+                       // And message producer
+                       this.messageProducer = this.session.createProducer(this.queue);
+
+                       // Finally the message instance itself
+                       this.message = this.session.createObjectMessage();
+               } catch (final NamingException | JMSException e) {
+                       // Continued to throw
+                       throw new FacesException(e);
+               }
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebSessionController.java
new file mode 100644 (file)
index 0000000..68abb89
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.checkout;
+
+import java.io.Serializable;
+import org.mxchange.jshopcore.model.customer.Customer;
+
+/**
+ * An interface for the shop
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface CheckoutWebSessionController extends Serializable {
+
+       /**
+        * Runs the actual checkout and returns a proper page redirection target.
+        * <p>
+        * @return Page redirection target
+        */
+       String doCheckout ();
+
+       /**
+        * Getter for customer instance
+        * <p>
+        * @return Customer instance
+        */
+       Customer getCustomer ();
+
+       /**
+        * Setter for customer instance
+        * <p>
+        * @param customer Customer instance
+        */
+       void setCustomer (final Customer customer);
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebApplicationBean.java
new file mode 100644 (file)
index 0000000..186de99
--- /dev/null
@@ -0,0 +1,82 @@
+package org.mxchange.pizzaapplication.beans.country;
+
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
+
+/**
+ * A country bean
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("country")
+@ApplicationScoped
+public class CountryWebApplicationBean implements CountryWebApplicationController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 176_985_298_681_742_960L;
+
+       /**
+        * Remote country EJB
+        */
+       private CountrySingletonBeanRemote countryBean;
+
+       /**
+        * List of all countries
+        */
+       private List<Country> countryList;
+
+       /**
+        * Default constructor
+        */
+       public CountryWebApplicationBean () {
+               // Try this
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the bean
+                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanLocal"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public List<Country> allCountries () {
+               // Return "cached" version
+               return Collections.unmodifiableList(this.countryList);
+       }
+
+       @PostConstruct
+       public void init () {
+               this.countryList = this.countryBean.allCountries();
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebApplicationController.java
new file mode 100644 (file)
index 0000000..a26fc29
--- /dev/null
@@ -0,0 +1,36 @@
+package org.mxchange.pizzaapplication.beans.country;
+
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcountry.data.Country;
+
+/**
+ * An interface for country beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface CountryWebApplicationController extends Serializable {
+
+       /**
+        * A list of all countries
+        * <p>
+        * @return All countries
+        */
+       List<Country> allCountries ();
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java
deleted file mode 100644 (file)
index e55683b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.mxchange.pizzaapplication.beans.country;
-
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
-
-/**
- * A country bean
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("country")
-@ApplicationScoped
-public class CountryWebBean implements CountryWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 176_985_298_681_742_960L;
-
-       /**
-        * Remote country EJB
-        */
-       private CountrySingletonBeanRemote countryBean;
-
-       /**
-        * List of all countries
-        */
-       private List<Country> countryList;
-
-       /**
-        * Default constructor
-        */
-       public CountryWebBean () {
-               // Try this
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanLocal"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public List<Country> allCountries () {
-               // Return "cached" version
-               return Collections.unmodifiableList(this.countryList);
-       }
-
-       @PostConstruct
-       public void init () {
-               this.countryList = this.countryBean.allCountries();
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java
deleted file mode 100644 (file)
index b9fac8c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.mxchange.pizzaapplication.beans.country;
-
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcountry.data.Country;
-
-/**
- * An interface for country beans
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface CountryWebController extends Serializable {
-
-       /**
-        * A list of all countries
-        * <p>
-        * @return All countries
-        */
-       List<Country> allCountries ();
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java
deleted file mode 100644 (file)
index 7e0710b..0000000
+++ /dev/null
@@ -1,296 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.customer;
-
-import javax.enterprise.context.SessionScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jshopcore.model.customer.Customer;
-import org.mxchange.jshopcore.model.customer.CustomerSessionBeanRemote;
-import org.mxchange.jshopcore.model.customer.ShopCustomer;
-
-/**
- * A customer bean which hides the customer instance
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("customerController")
-@SessionScoped
-public class CustomerWebBean implements CustomerWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 542_145_347_916L;
-
-       /////////////////////// Properties /////////////////////
-       /**
-        * Cellphone number
-        */
-       private DialableCellphoneNumber cellphoneNumber;
-
-       /**
-        * City
-        */
-       private String city;
-
-       /**
-        * Optional comments
-        */
-       private String comment;
-
-       /**
-        * Country code
-        */
-       private Country country;
-
-       /**
-        * Remote customer bean
-        */
-       private CustomerSessionBeanRemote customerBean;
-
-       /**
-        * Email address
-        */
-       private String emailAddress;
-
-       /**
-        * Family name
-        */
-       private String familyName;
-
-       /**
-        * Fax number
-        */
-       private DialableFaxNumber faxNumber;
-
-       /**
-        * First name
-        */
-       private String firstName;
-
-       /**
-        * Gender instance
-        */
-       private Gender gender;
-
-       /**
-        * House number
-        */
-       private Short houseNumber;
-
-       /**
-        * Phone number
-        */
-       private DialableLandLineNumber phoneNumber;
-
-       /**
-        * Street
-        */
-       private String street;
-
-       /**
-        * ZIP code
-        */
-       private Integer zipCode;
-
-       /**
-        * Default constructor
-        */
-       public CustomerWebBean () {
-               // Set gender to UNKNOWN
-               this.gender = Gender.UNKNOWN;
-
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.customerBean = (CustomerSessionBeanRemote) context.lookup("ejb/stateless-customer");
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
-       }
-
-       @Override
-       public Customer createCustomerInstance () {
-               // Trace message
-               //this.getLogger().logTrace("createInstance: CALLED!");
-
-               // Required personal data must be set
-               assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
-
-               // Create new customer instance
-               Customer customer = new ShopCustomer();
-
-               // Create new contact
-               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
-               contact.setContactStreet(this.getStreet());
-               contact.setContactHouseNumber(this.getHouseNumber());
-               contact.setContactZipCode(this.getZipCode());
-               contact.setContactCity(this.getCity());
-               contact.setContactCountry(this.getCountry());
-               contact.setContactPhoneNumber(this.getPhoneNumber());
-               contact.setContactFaxNumber(this.getFaxNumber());
-               contact.setContactCellphoneNumber(this.getCellphoneNumber());
-
-               // Set contact in customer
-               customer.setContact(contact);
-
-               // Trace message
-               //this.getLogger().logTrace(MessageFormat.format("createInstance: customer={0} - EXIT!", customer));
-               // Return it
-               return customer;
-       }
-
-       @Override
-       public DialableCellphoneNumber getCellphoneNumber () {
-               return this.cellphoneNumber;
-       }
-
-       @Override
-       public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
-               this.cellphoneNumber = cellphoneNumber;
-       }
-
-       @Override
-       public String getCity () {
-               return this.city;
-       }
-
-       @Override
-       public void setCity (final String city) {
-               this.city = city;
-       }
-
-       @Override
-       public Country getCountry () {
-               return this.country;
-       }
-
-       @Override
-       public void setCountry (final Country country) {
-               this.country = country;
-       }
-
-       @Override
-       public String getEmailAddress () {
-               return this.emailAddress;
-       }
-
-       @Override
-       public void setEmailAddress (final String emailAddress) {
-               this.emailAddress = emailAddress;
-       }
-
-       @Override
-       public String getFamilyName () {
-               return this.familyName;
-       }
-
-       @Override
-       public void setFamilyName (final String familyName) {
-               this.familyName = familyName;
-       }
-
-       @Override
-       public DialableFaxNumber getFaxNumber () {
-               return this.faxNumber;
-       }
-
-       @Override
-       public void setFaxNumber (final DialableFaxNumber faxNumber) {
-               this.faxNumber = faxNumber;
-       }
-
-       @Override
-       public String getFirstName () {
-               return this.firstName;
-       }
-
-       @Override
-       public void setFirstName (final String firstName) {
-               this.firstName = firstName;
-       }
-
-       @Override
-       public Gender getGender () {
-               return this.gender;
-       }
-
-       @Override
-       public void setGender (final Gender gender) {
-               this.gender = gender;
-       }
-
-       @Override
-       public Short getHouseNumber () {
-               return this.houseNumber;
-       }
-
-       @Override
-       public void setHouseNumber (final Short houseNumber) {
-               this.houseNumber = houseNumber;
-       }
-
-       @Override
-       public DialableLandLineNumber getPhoneNumber () {
-               return this.phoneNumber;
-       }
-
-       @Override
-       public void setPhoneNumber (final DialableLandLineNumber phoneNumber) {
-               this.phoneNumber = phoneNumber;
-       }
-
-       @Override
-       public String getStreet () {
-               return this.street;
-       }
-
-       @Override
-       public void setStreet (final String street) {
-               this.street = street;
-       }
-
-       @Override
-       public Integer getZipCode () {
-               return this.zipCode;
-       }
-
-       @Override
-       public void setZipCode (final Integer zipCode) {
-               this.zipCode = zipCode;
-       }
-
-       @Override
-       public boolean isRequiredPersonalDataSet () {
-               return ((this.getGender() != null) && (this.getFirstName() != null) && (this.getFamilyName() != null) && (this.getStreet() != null) && (this.getHouseNumber() != null) && (this.getZipCode() != null) && (this.getCity() != null));
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java
deleted file mode 100644 (file)
index 13d3fa7..0000000
+++ /dev/null
@@ -1,215 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.customer;
-
-import java.io.Serializable;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jshopcore.model.customer.Customer;
-
-/**
- * An interface for customer beans
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface CustomerWebController extends Serializable {
-
-       /**
-        * Creates an instance from all properties
-        * <p>
-        * @return A Customer instance
-        */
-       Customer createCustomerInstance ();
-
-       /**
-        * Cellphone number
-        * <p>
-        * @return the cellphoneNumber
-        */
-       DialableCellphoneNumber getCellphoneNumber ();
-
-       /**
-        * Cellphone number
-        * <p>
-        * @param cellphoneNumber the cellphoneNumber to set
-        */
-       void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber);
-
-       /**
-        * City
-        * <p>
-        * @return the city
-        */
-       String getCity ();
-
-       /**
-        * City
-        * <p>
-        * @param city the city to set
-        */
-       void setCity (final String city);
-
-       /**
-        * Getter for country instance
-        * <p>
-        * @return Country instance
-        */
-       Country getCountry ();
-
-       /**
-        * Setter for country instance
-        * <p>
-        * @param country Country instance
-        */
-       void setCountry (final Country country);
-
-       /**
-        * Email address
-        * <p>
-        * @return the emailAddress
-        */
-       String getEmailAddress ();
-
-       /**
-        * Email address
-        * <p>
-        * @param emailAddress the emailAddress to set
-        */
-       void setEmailAddress (final String emailAddress);
-
-       /**
-        * Family name
-        * <p>
-        * @return the familyName
-        */
-       String getFamilyName ();
-
-       /**
-        * Family name
-        * <p>
-        * @param familyName the familyName to set
-        */
-       void setFamilyName (final String familyName);
-
-       /**
-        * Fax number
-        * <p>
-        * @return the faxNumber
-        */
-       DialableFaxNumber getFaxNumber ();
-
-       /**
-        * Fax number
-        * <p>
-        * @param faxNumber the faxNumber to set
-        */
-       void setFaxNumber (final DialableFaxNumber faxNumber);
-
-       /**
-        * First name
-        * <p>
-        * @return the first name
-        */
-       String getFirstName ();
-
-       /**
-        * First name
-        * <p>
-        * @param firstName the first name to set
-        */
-       void setFirstName (final String firstName);
-
-       /**
-        * Gender of the contact
-        * <p>
-        * @return the gender
-        */
-       Gender getGender ();
-
-       /**
-        * Gender of the contact
-        * <p>
-        * @param gender the gender to set
-        */
-       void setGender (final Gender gender);
-
-       /**
-        * House number
-        * <p>
-        * @return the houseNumber
-        */
-       Short getHouseNumber ();
-
-       /**
-        * House number
-        * <p>
-        * @param houseNumber the houseNumber to set
-        */
-       void setHouseNumber (final Short houseNumber);
-
-       /**
-        * Phone number
-        * <p>
-        * @return the phoneNumber
-        */
-       DialableLandLineNumber getPhoneNumber ();
-
-       /**
-        * Phone number
-        * <p>
-        * @param phoneNumber the phoneNumber to set
-        */
-       void setPhoneNumber (final DialableLandLineNumber phoneNumber);
-
-       /**
-        * Street
-        * <p>
-        * @return the street
-        */
-       String getStreet ();
-
-       /**
-        * Street
-        * <p>
-        * @param street the street to set
-        */
-       void setStreet (final String street);
-
-       /**
-        * ZIP code
-        * <p>
-        * @return the zipCode
-        */
-       Integer getZipCode ();
-
-       /**
-        * ZIP code
-        * <p>
-        * @param zipCode the zipCode to set
-        */
-       void setZipCode (final Integer zipCode);
-
-       /**
-        * Checks whether all required personal data is set
-        * <p>
-        * @return Whether the required personal data is set
-        */
-       boolean isRequiredPersonalDataSet ();
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebSessionBean.java
new file mode 100644 (file)
index 0000000..f8a9a81
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.customer;
+
+import javax.enterprise.context.SessionScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jshopcore.model.customer.Customer;
+import org.mxchange.jshopcore.model.customer.CustomerSessionBeanRemote;
+import org.mxchange.jshopcore.model.customer.ShopCustomer;
+
+/**
+ * A customer bean which hides the customer instance
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("customerController")
+@SessionScoped
+public class CustomerWebSessionBean implements CustomerWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /////////////////////// Properties /////////////////////
+       /**
+        * Cellphone number
+        */
+       private DialableCellphoneNumber cellphoneNumber;
+
+       /**
+        * City
+        */
+       private String city;
+
+       /**
+        * Optional comments
+        */
+       private String comment;
+
+       /**
+        * Country code
+        */
+       private Country country;
+
+       /**
+        * Remote customer bean
+        */
+       private CustomerSessionBeanRemote customerBean;
+
+       /**
+        * Email address
+        */
+       private String emailAddress;
+
+       /**
+        * Family name
+        */
+       private String familyName;
+
+       /**
+        * Fax number
+        */
+       private DialableFaxNumber faxNumber;
+
+       /**
+        * First name
+        */
+       private String firstName;
+
+       /**
+        * Gender instance
+        */
+       private Gender gender;
+
+       /**
+        * House number
+        */
+       private Short houseNumber;
+
+       /**
+        * Phone number
+        */
+       private DialableLandLineNumber phoneNumber;
+
+       /**
+        * Street
+        */
+       private String street;
+
+       /**
+        * ZIP code
+        */
+       private Integer zipCode;
+
+       /**
+        * Default constructor
+        */
+       public CustomerWebSessionBean () {
+               // Set gender to UNKNOWN
+               this.gender = Gender.UNKNOWN;
+
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.customerBean = (CustomerSessionBeanRemote) context.lookup("ejb/stateless-customer");
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
+       @Override
+       public Customer createCustomerInstance () {
+               // Trace message
+               //this.getLogger().logTrace("createInstance: CALLED!");
+
+               // Required personal data must be set
+               assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+               // Create new customer instance
+               Customer customer = new ShopCustomer();
+
+               // Create new contact
+               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+               contact.setContactStreet(this.getStreet());
+               contact.setContactHouseNumber(this.getHouseNumber());
+               contact.setContactZipCode(this.getZipCode());
+               contact.setContactCity(this.getCity());
+               contact.setContactCountry(this.getCountry());
+               contact.setContactPhoneNumber(this.getPhoneNumber());
+               contact.setContactFaxNumber(this.getFaxNumber());
+               contact.setContactCellphoneNumber(this.getCellphoneNumber());
+
+               // Set contact in customer
+               customer.setContact(contact);
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("createInstance: customer={0} - EXIT!", customer));
+               // Return it
+               return customer;
+       }
+
+       @Override
+       public DialableCellphoneNumber getCellphoneNumber () {
+               return this.cellphoneNumber;
+       }
+
+       @Override
+       public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
+               this.cellphoneNumber = cellphoneNumber;
+       }
+
+       @Override
+       public String getCity () {
+               return this.city;
+       }
+
+       @Override
+       public void setCity (final String city) {
+               this.city = city;
+       }
+
+       @Override
+       public Country getCountry () {
+               return this.country;
+       }
+
+       @Override
+       public void setCountry (final Country country) {
+               this.country = country;
+       }
+
+       @Override
+       public String getEmailAddress () {
+               return this.emailAddress;
+       }
+
+       @Override
+       public void setEmailAddress (final String emailAddress) {
+               this.emailAddress = emailAddress;
+       }
+
+       @Override
+       public String getFamilyName () {
+               return this.familyName;
+       }
+
+       @Override
+       public void setFamilyName (final String familyName) {
+               this.familyName = familyName;
+       }
+
+       @Override
+       public DialableFaxNumber getFaxNumber () {
+               return this.faxNumber;
+       }
+
+       @Override
+       public void setFaxNumber (final DialableFaxNumber faxNumber) {
+               this.faxNumber = faxNumber;
+       }
+
+       @Override
+       public String getFirstName () {
+               return this.firstName;
+       }
+
+       @Override
+       public void setFirstName (final String firstName) {
+               this.firstName = firstName;
+       }
+
+       @Override
+       public Gender getGender () {
+               return this.gender;
+       }
+
+       @Override
+       public void setGender (final Gender gender) {
+               this.gender = gender;
+       }
+
+       @Override
+       public Short getHouseNumber () {
+               return this.houseNumber;
+       }
+
+       @Override
+       public void setHouseNumber (final Short houseNumber) {
+               this.houseNumber = houseNumber;
+       }
+
+       @Override
+       public DialableLandLineNumber getPhoneNumber () {
+               return this.phoneNumber;
+       }
+
+       @Override
+       public void setPhoneNumber (final DialableLandLineNumber phoneNumber) {
+               this.phoneNumber = phoneNumber;
+       }
+
+       @Override
+       public String getStreet () {
+               return this.street;
+       }
+
+       @Override
+       public void setStreet (final String street) {
+               this.street = street;
+       }
+
+       @Override
+       public Integer getZipCode () {
+               return this.zipCode;
+       }
+
+       @Override
+       public void setZipCode (final Integer zipCode) {
+               this.zipCode = zipCode;
+       }
+
+       @Override
+       public boolean isRequiredPersonalDataSet () {
+               return ((this.getGender() != null) && (this.getFirstName() != null) && (this.getFamilyName() != null) && (this.getStreet() != null) && (this.getHouseNumber() != null) && (this.getZipCode() != null) && (this.getCity() != null));
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebSessionController.java
new file mode 100644 (file)
index 0000000..9eac772
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.customer;
+
+import java.io.Serializable;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jshopcore.model.customer.Customer;
+
+/**
+ * An interface for customer beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface CustomerWebSessionController extends Serializable {
+
+       /**
+        * Creates an instance from all properties
+        * <p>
+        * @return A Customer instance
+        */
+       Customer createCustomerInstance ();
+
+       /**
+        * Cellphone number
+        * <p>
+        * @return the cellphoneNumber
+        */
+       DialableCellphoneNumber getCellphoneNumber ();
+
+       /**
+        * Cellphone number
+        * <p>
+        * @param cellphoneNumber the cellphoneNumber to set
+        */
+       void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber);
+
+       /**
+        * City
+        * <p>
+        * @return the city
+        */
+       String getCity ();
+
+       /**
+        * City
+        * <p>
+        * @param city the city to set
+        */
+       void setCity (final String city);
+
+       /**
+        * Getter for country instance
+        * <p>
+        * @return Country instance
+        */
+       Country getCountry ();
+
+       /**
+        * Setter for country instance
+        * <p>
+        * @param country Country instance
+        */
+       void setCountry (final Country country);
+
+       /**
+        * Email address
+        * <p>
+        * @return the emailAddress
+        */
+       String getEmailAddress ();
+
+       /**
+        * Email address
+        * <p>
+        * @param emailAddress the emailAddress to set
+        */
+       void setEmailAddress (final String emailAddress);
+
+       /**
+        * Family name
+        * <p>
+        * @return the familyName
+        */
+       String getFamilyName ();
+
+       /**
+        * Family name
+        * <p>
+        * @param familyName the familyName to set
+        */
+       void setFamilyName (final String familyName);
+
+       /**
+        * Fax number
+        * <p>
+        * @return the faxNumber
+        */
+       DialableFaxNumber getFaxNumber ();
+
+       /**
+        * Fax number
+        * <p>
+        * @param faxNumber the faxNumber to set
+        */
+       void setFaxNumber (final DialableFaxNumber faxNumber);
+
+       /**
+        * First name
+        * <p>
+        * @return the first name
+        */
+       String getFirstName ();
+
+       /**
+        * First name
+        * <p>
+        * @param firstName the first name to set
+        */
+       void setFirstName (final String firstName);
+
+       /**
+        * Gender of the contact
+        * <p>
+        * @return the gender
+        */
+       Gender getGender ();
+
+       /**
+        * Gender of the contact
+        * <p>
+        * @param gender the gender to set
+        */
+       void setGender (final Gender gender);
+
+       /**
+        * House number
+        * <p>
+        * @return the houseNumber
+        */
+       Short getHouseNumber ();
+
+       /**
+        * House number
+        * <p>
+        * @param houseNumber the houseNumber to set
+        */
+       void setHouseNumber (final Short houseNumber);
+
+       /**
+        * Phone number
+        * <p>
+        * @return the phoneNumber
+        */
+       DialableLandLineNumber getPhoneNumber ();
+
+       /**
+        * Phone number
+        * <p>
+        * @param phoneNumber the phoneNumber to set
+        */
+       void setPhoneNumber (final DialableLandLineNumber phoneNumber);
+
+       /**
+        * Street
+        * <p>
+        * @return the street
+        */
+       String getStreet ();
+
+       /**
+        * Street
+        * <p>
+        * @param street the street to set
+        */
+       void setStreet (final String street);
+
+       /**
+        * ZIP code
+        * <p>
+        * @return the zipCode
+        */
+       Integer getZipCode ();
+
+       /**
+        * ZIP code
+        * <p>
+        * @param zipCode the zipCode to set
+        */
+       void setZipCode (final Integer zipCode);
+
+       /**
+        * Checks whether all required personal data is set
+        * <p>
+        * @return Whether the required personal data is set
+        */
+       boolean isRequiredPersonalDataSet ();
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebApplicationBean.java
new file mode 100644 (file)
index 0000000..473b141
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.gender;
+
+import java.util.List;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.gender.GenderUtils;
+
+/**
+ * A gender bean (controller)
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("gender")
+@ApplicationScoped
+public class GenderWebApplicationBean implements GenderWebApplicationController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 835_482_364_189L;
+
+       /**
+        * Default constructor
+        */
+       public GenderWebApplicationBean () {
+       }
+
+       @Override
+       public Gender[] getAllGenders () {
+               // Return it
+               return Gender.values();
+       }
+
+       @Override
+       public List<Gender> getSelectableGenders () {
+               // Init array
+               // TODO Call EJB here?
+               List<Gender> genders = GenderUtils.selectableGenders();
+
+               // Return it
+               return genders;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebApplicationController.java
new file mode 100644 (file)
index 0000000..d547f95
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.gender;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontacts.contact.gender.Gender;
+
+/**
+ * An interface for data beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface GenderWebApplicationController extends Serializable {
+
+       /**
+        * Getter for all genders as array
+        * <p>
+        * @return All genders as array
+        */
+       Gender[] getAllGenders ();
+
+       /**
+        * Getter for only selectable genders as array, UNKNOWN is not selectable
+        * <p>
+        * @return All genders as array
+        */
+       List<Gender> getSelectableGenders ();
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java
deleted file mode 100644 (file)
index 72029bf..0000000
+++ /dev/null
@@ -1,60 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.gender;
-
-import java.util.List;
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Named;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.contact.gender.GenderUtils;
-
-/**
- * A gender bean (controller)
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("gender")
-@ApplicationScoped
-public class GenderWebBean implements GenderWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 835_482_364_189L;
-
-       /**
-        * Default constructor
-        */
-       public GenderWebBean () {
-       }
-
-       @Override
-       public Gender[] getAllGenders () {
-               // Return it
-               return Gender.values();
-       }
-
-       @Override
-       public List<Gender> getSelectableGenders () {
-               // Init array
-               // TODO Call EJB here?
-               List<Gender> genders = GenderUtils.selectableGenders();
-
-               // Return it
-               return genders;
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java b/src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebController.java
deleted file mode 100644 (file)
index 5618aa6..0000000
+++ /dev/null
@@ -1,43 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.gender;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontacts.contact.gender.Gender;
-
-/**
- * An interface for data beans
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface GenderWebController extends Serializable {
-
-       /**
-        * Getter for all genders as array
-        * <p>
-        * @return All genders as array
-        */
-       Gender[] getAllGenders ();
-
-       /**
-        * Getter for only selectable genders as array, UNKNOWN is not selectable
-        * <p>
-        * @return All genders as array
-        */
-       List<Gender> getSelectableGenders ();
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java
deleted file mode 100644 (file)
index 8c7c9b0..0000000
+++ /dev/null
@@ -1,174 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.product;
-
-import java.util.List;
-import javax.enterprise.context.RequestScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.exceptions.CannotAddProductException;
-import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.product.AdminProductSessionBeanRemote;
-import org.mxchange.jshopcore.model.product.GenericProduct;
-import org.mxchange.jshopcore.model.product.Product;
-import org.mxchange.pizzaapplication.beans.shop.ShopWebController;
-
-/**
- * Main application class
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("admin_product")
-@RequestScoped
-public class AdminProductWebBean implements AdminProductWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 5_819_375_183_472_871L;
-
-       /////////////////////// Properties /////////////////////
-       /**
-        * Available
-        */
-       private Boolean productAvailability;
-
-       /**
-        * Category instance
-        */
-       private Category productCategory;
-
-       /**
-        * Property productPrice
-        */
-       private Float productPrice;
-
-       /**
-        * Remote bean for products
-        */
-       private AdminProductSessionBeanRemote productRemoteBean;
-
-       /**
-        * Property productTitle
-        */
-       private String productTitle;
-
-       ////////////////////// Bean injections ///////////////////////
-
-       /**
-        * Shop bean
-        */
-       @Inject
-       private ShopWebController shopController;
-
-       /**
-        * Default constructor
-        */
-       public AdminProductWebBean () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       this.productRemoteBean = (AdminProductSessionBeanRemote) context.lookup("ejb/stateless-admin-product"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw it again
-                       throw new FaceletException(e);
-               }
-       }
-
-       @Override
-       public void addProduct () throws FaceletException {
-               try {
-                       // Create product instance
-                       Product product = new GenericProduct();
-
-                       // Add all
-                       product.setProductAvailability(this.getProductAvailability());
-                       product.setProductCategory(this.getProductCategory());
-                       product.setProductPrice(this.getProductPrice());
-                       product.setProductTitle(this.getProductTitle());
-
-                       // Call bean
-                       Product updatedProduct = this.productRemoteBean.doAdminAddProduct(product);
-
-                       // Add to shop controller
-                       this.shopController.addProduct(updatedProduct);
-
-                       // Set all to null
-                       this.setProductAvailability(Boolean.FALSE);
-                       this.setProductCategory(null);
-                       this.setProductPrice(null);
-                       this.setProductTitle(null);
-               } catch (final ProductTitleAlreadyUsedException | CannotAddProductException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public List<Product> getAllProducts () throws FaceletException {
-               // Call bean
-               return this.productRemoteBean.getAllProducts();
-       }
-
-       @Override
-       public Boolean getProductAvailability () {
-               return this.productAvailability;
-       }
-
-       @Override
-       public void setProductAvailability (final Boolean productAvailability) {
-               this.productAvailability = productAvailability;
-       }
-
-       @Override
-       public Category getProductCategory () {
-               return this.productCategory;
-       }
-
-       @Override
-       public void setProductCategory (final Category productCategory) {
-               this.productCategory = productCategory;
-       }
-
-       @Override
-       public Float getProductPrice () {
-               return this.productPrice;
-       }
-
-       @Override
-       public void setProductPrice (final Float productPrice) {
-               this.productPrice = productPrice;
-       }
-
-       @Override
-       public String getProductTitle () {
-               return this.productTitle;
-       }
-
-       @Override
-       public void setProductTitle (final String productTitle) {
-               this.productTitle = productTitle;
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebController.java
deleted file mode 100644 (file)
index ac384d7..0000000
+++ /dev/null
@@ -1,103 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.product;
-
-import java.util.List;
-import javax.faces.view.facelets.FaceletException;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.product.Product;
-
-/**
- * An interface for product controllers for "ADMIN" role
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface AdminProductWebController {
-
-       /**
-        * Adds given product data from request to database
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If something
-        * unexpected happened
-        */
-       void addProduct () throws FaceletException;
-
-       /**
-        * Some "getter" for a linked list of all products
-        * <p>
-        * @return All products
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
-        */
-       List<Product> getAllProducts () throws FaceletException;
-
-       /**
-        * Getter for product's available property
-        * <p>
-        * @return Product's available property
-        */
-       Boolean getProductAvailability ();
-
-       /**
-        * Setter for product's available property
-        * <p>
-        * @param available Product's available property
-        */
-       void setProductAvailability (final Boolean available);
-
-       /**
-        * Getter for product's category
-        * <p>
-        * @return Product's category
-        */
-       Category getProductCategory ();
-
-       /**
-        * Setter for product's category instance
-        * <p>
-        * @param productCategory Product's category instance
-        */
-       void setProductCategory (final Category productCategory);
-
-       /**
-        * Getter for product's price property
-        * <p>
-        * @return Product's price property
-        */
-       Float getProductPrice ();
-
-       /**
-        * Setter for product's price property
-        * <p>
-        * @param price Product's price property
-        */
-       void setProductPrice (final Float price);
-
-       /**
-        * Getter for product's title property
-        * <p>
-        * @return Product's title
-        */
-       String getProductTitle ();
-
-       /**
-        * Setter for product's title property
-        * <p>
-        * @param title Product's title
-        */
-       void setProductTitle (final String title);
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebRequestBean.java
new file mode 100644 (file)
index 0000000..2e3f50f
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.product;
+
+import java.util.List;
+import javax.enterprise.context.RequestScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.exceptions.CannotAddProductException;
+import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.product.AdminProductSessionBeanRemote;
+import org.mxchange.jshopcore.model.product.GenericProduct;
+import org.mxchange.jshopcore.model.product.Product;
+import org.mxchange.pizzaapplication.beans.shop.ShopWebApplicationController;
+
+/**
+ * Main application class
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("adminProductController")
+@RequestScoped
+public class AdminProductWebRequestBean implements AdminProductWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_819_375_183_472_871L;
+
+       /////////////////////// Properties /////////////////////
+       /**
+        * Available
+        */
+       private Boolean productAvailability;
+
+       /**
+        * Category instance
+        */
+       private Category productCategory;
+
+       /**
+        * Property productPrice
+        */
+       private Float productPrice;
+
+       /**
+        * Remote bean for products
+        */
+       private AdminProductSessionBeanRemote productRemoteBean;
+
+       /**
+        * Property productTitle
+        */
+       private String productTitle;
+
+       ////////////////////// Bean injections ///////////////////////
+
+       /**
+        * Shop bean
+        */
+       @Inject
+       private ShopWebApplicationController shopController;
+
+       /**
+        * Default constructor
+        */
+       public AdminProductWebRequestBean () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the bean
+                       this.productRemoteBean = (AdminProductSessionBeanRemote) context.lookup("ejb/stateless-admin-product"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw it again
+                       throw new FaceletException(e);
+               }
+       }
+
+       @Override
+       public void addProduct () throws FaceletException {
+               try {
+                       // Create product instance
+                       Product product = new GenericProduct();
+
+                       // Add all
+                       product.setProductAvailability(this.getProductAvailability());
+                       product.setProductCategory(this.getProductCategory());
+                       product.setProductPrice(this.getProductPrice());
+                       product.setProductTitle(this.getProductTitle());
+
+                       // Call bean
+                       Product updatedProduct = this.productRemoteBean.doAdminAddProduct(product);
+
+                       // Add to shop controller
+                       this.shopController.addProduct(updatedProduct);
+
+                       // Set all to null
+                       this.setProductAvailability(Boolean.FALSE);
+                       this.setProductCategory(null);
+                       this.setProductPrice(null);
+                       this.setProductTitle(null);
+               } catch (final ProductTitleAlreadyUsedException | CannotAddProductException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public List<Product> getAllProducts () throws FaceletException {
+               // Call bean
+               return this.productRemoteBean.getAllProducts();
+       }
+
+       @Override
+       public Boolean getProductAvailability () {
+               return this.productAvailability;
+       }
+
+       @Override
+       public void setProductAvailability (final Boolean productAvailability) {
+               this.productAvailability = productAvailability;
+       }
+
+       @Override
+       public Category getProductCategory () {
+               return this.productCategory;
+       }
+
+       @Override
+       public void setProductCategory (final Category productCategory) {
+               this.productCategory = productCategory;
+       }
+
+       @Override
+       public Float getProductPrice () {
+               return this.productPrice;
+       }
+
+       @Override
+       public void setProductPrice (final Float productPrice) {
+               this.productPrice = productPrice;
+       }
+
+       @Override
+       public String getProductTitle () {
+               return this.productTitle;
+       }
+
+       @Override
+       public void setProductTitle (final String productTitle) {
+               this.productTitle = productTitle;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebRequestController.java
new file mode 100644 (file)
index 0000000..9545006
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.product;
+
+import java.util.List;
+import javax.faces.view.facelets.FaceletException;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * An interface for product controllers for "ADMIN" role
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminProductWebRequestController {
+
+       /**
+        * Adds given product data from request to database
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If something
+        * unexpected happened
+        */
+       void addProduct () throws FaceletException;
+
+       /**
+        * Some "getter" for a linked list of all products
+        * <p>
+        * @return All products
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+        */
+       List<Product> getAllProducts () throws FaceletException;
+
+       /**
+        * Getter for product's available property
+        * <p>
+        * @return Product's available property
+        */
+       Boolean getProductAvailability ();
+
+       /**
+        * Setter for product's available property
+        * <p>
+        * @param available Product's available property
+        */
+       void setProductAvailability (final Boolean available);
+
+       /**
+        * Getter for product's category
+        * <p>
+        * @return Product's category
+        */
+       Category getProductCategory ();
+
+       /**
+        * Setter for product's category instance
+        * <p>
+        * @param productCategory Product's category instance
+        */
+       void setProductCategory (final Category productCategory);
+
+       /**
+        * Getter for product's price property
+        * <p>
+        * @return Product's price property
+        */
+       Float getProductPrice ();
+
+       /**
+        * Setter for product's price property
+        * <p>
+        * @param price Product's price property
+        */
+       void setProductPrice (final Float price);
+
+       /**
+        * Getter for product's title property
+        * <p>
+        * @return Product's title
+        */
+       String getProductTitle ();
+
+       /**
+        * Setter for product's title property
+        * <p>
+        * @param title Product's title
+        */
+       void setProductTitle (final String title);
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebBean.java
deleted file mode 100644 (file)
index 7874c92..0000000
+++ /dev/null
@@ -1,82 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.receipt;
-
-import javax.enterprise.context.SessionScoped;
-import javax.faces.FacesException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.model.customer.Customer;
-import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
-
-/**
- * Checkout controller
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("receiptController")
-@SessionScoped
-public class ReceiptWebBean implements ReceiptWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 95_723_834_783_478_781L;
-
-       /**
-        * Customer instance
-        */
-       private Customer customer;
-
-       /**
-        * Remote bean instance
-        */
-       private ReceiptBeanRemote receiptBean;
-
-       /**
-        * Default constructor
-        */
-       public ReceiptWebBean () {
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Get factory from JMS resource
-                       this.receiptBean = (ReceiptBeanRemote) context.lookup("ejb/stateless-receipt");
-               } catch (final NamingException e) {
-                       // Continued to throw
-                       throw new FacesException(e);
-               }
-       }
-
-       @Override
-       public String fetchAccessKey () {
-               return this.receiptBean.fetchAccessKey(this.getCustomer());
-       }
-
-       @Override
-       public Customer getCustomer () {
-               return this.customer;
-       }
-
-       @Override
-       public void setCustomer (final Customer customer) {
-               this.customer = customer;
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebController.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebController.java
deleted file mode 100644 (file)
index 85e85e9..0000000
+++ /dev/null
@@ -1,49 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.receipt;
-
-import java.io.Serializable;
-import org.mxchange.jshopcore.model.customer.Customer;
-
-/**
- * An interface for the shop
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface ReceiptWebController extends Serializable {
-
-       /**
-        * Fetches last access key for given customer instance
-        * <p>
-        * @return Access key to receipt
-        */
-       String fetchAccessKey ();
-
-       /**
-        * Getter for customer instamce
-        * <p>
-        * @return Customer instance
-        */
-       Customer getCustomer ();
-
-       /**
-        * Setter for customer instamce
-        * <p>
-        * @param customer Customer instance
-        */
-       void setCustomer (final Customer customer);
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebSessionBean.java
new file mode 100644 (file)
index 0000000..6d46933
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.receipt;
+
+import javax.enterprise.context.SessionScoped;
+import javax.faces.FacesException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.model.customer.Customer;
+import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
+
+/**
+ * Checkout controller
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("receiptController")
+@SessionScoped
+public class ReceiptWebSessionBean implements ReceiptWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 95_723_834_783_478_781L;
+
+       /**
+        * Customer instance
+        */
+       private Customer customer;
+
+       /**
+        * Remote bean instance
+        */
+       private ReceiptBeanRemote receiptBean;
+
+       /**
+        * Default constructor
+        */
+       public ReceiptWebSessionBean () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Get factory from JMS resource
+                       this.receiptBean = (ReceiptBeanRemote) context.lookup("ejb/stateless-receipt");
+               } catch (final NamingException e) {
+                       // Continued to throw
+                       throw new FacesException(e);
+               }
+       }
+
+       @Override
+       public String fetchAccessKey () {
+               return this.receiptBean.fetchAccessKey(this.getCustomer());
+       }
+
+       @Override
+       public Customer getCustomer () {
+               return this.customer;
+       }
+
+       @Override
+       public void setCustomer (final Customer customer) {
+               this.customer = customer;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/ReceiptWebSessionController.java
new file mode 100644 (file)
index 0000000..fa0f3fd
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.receipt;
+
+import java.io.Serializable;
+import org.mxchange.jshopcore.model.customer.Customer;
+
+/**
+ * An interface for the shop
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface ReceiptWebSessionController extends Serializable {
+
+       /**
+        * Fetches last access key for given customer instance
+        * <p>
+        * @return Access key to receipt
+        */
+       String fetchAccessKey ();
+
+       /**
+        * Getter for customer instamce
+        * <p>
+        * @return Customer instance
+        */
+       Customer getCustomer ();
+
+       /**
+        * Setter for customer instamce
+        * <p>
+        * @param customer Customer instance
+        */
+       void setCustomer (final Customer customer);
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebApplicationBean.java
new file mode 100644 (file)
index 0000000..daf67bb
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.shop;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
+import org.mxchange.jshopcore.model.product.Product;
+import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
+
+/**
+ * General shop controller
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("controller")
+@ApplicationScoped
+public class ShopWebApplicationBean implements ShopWebApplicationController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_137_539_530_279L;
+
+       /**
+        * "Cache" for all available products
+        */
+       private List<Product> availableProducts;
+
+       /**
+        * All categories
+        */
+       private List<Category> categories;
+
+       @Override
+       public void addCategory (final Category category) {
+               // Add the category
+               this.categories.add(category);
+       }
+
+       @Override
+       public void addProduct (final Product product) {
+               // Is the product available?
+               if (product.getProductAvailability()) {
+                       // Add it
+                       this.availableProducts.add(product);
+               }
+       }
+
+       @Override
+       public List<Category> getAllCategories () throws FacesException {
+               // Return it
+               // TODO Find something better here to prevent warning
+               return Collections.unmodifiableList(this.categories);
+       }
+
+       @Override
+       public List<Category> getAllCategoriesParent () throws FaceletException {
+               // Get regular list
+               List<Category> list = new LinkedList<>(this.getAllCategories());
+
+               // Return it
+               return list;
+       }
+
+       @Override
+       public List<Product> getAvailableProducts () throws FacesException {
+               // Return it
+               // TODO Find something better here to prevent warning
+               return Collections.unmodifiableList(this.availableProducts);
+       }
+
+       /**
+        * Initialization of this bean
+        */
+       @PostConstruct
+       public void init () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the bean
+                       CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N
+
+                       // Get all categories
+                       this.categories = categoryBean.getAllCategories();
+
+                       // Try to lookup the bean
+                       ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N
+
+                       // Get available products list
+                       this.availableProducts = productBean.getAvailableProducts();
+               } catch (final NamingException e) {
+                       // Continued to throw
+                       throw new FacesException(e);
+               }
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebApplicationController.java
new file mode 100644 (file)
index 0000000..6968a17
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.shop;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.faces.view.facelets.FaceletException;
+import org.mxchange.jshopcore.model.category.Category;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * An interface for the shop
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface ShopWebApplicationController extends Serializable {
+
+       /**
+        * Adds given category to the "cached" instance
+        * <p>
+        * @param category Category instance
+        */
+       void addCategory (final Category category);
+
+       /**
+        * Adds given product to the "cached" instance
+        * <p>
+        * @param product Product instance
+        */
+       void addProduct (final Product product);
+
+       /**
+        * Some "getter" for a linked list of all categories
+        * <p>
+        * @return All categories
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+        */
+       List<Category> getAllCategories () throws FaceletException;
+
+       /**
+        * Some "getter" for a linked list of all categories including "Has no
+        * parent" fake category.
+        * <p>
+        * @return All categories
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+        */
+       List<Category> getAllCategoriesParent () throws FaceletException;
+
+       /**
+        * Some "getter" for a linked list of only available products
+        * <p>
+        * @return Only available products
+        * <p>
+        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
+        */
+       List<Product> getAvailableProducts () throws FaceletException;
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebBean.java
deleted file mode 100644 (file)
index d661a29..0000000
+++ /dev/null
@@ -1,123 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.shop;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.faces.FacesException;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
-import org.mxchange.jshopcore.model.product.Product;
-import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
-import org.mxchange.pizzaapplication.beans.AbstractWebBean;
-
-/**
- * General shop controller
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("controller")
-@ApplicationScoped
-public class ShopWebBean extends AbstractWebBean implements ShopWebController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 58_137_539_530_279L;
-
-       /**
-        * "Cache" for all available products
-        */
-       private List<Product> availableProducts;
-
-       /**
-        * All categories
-        */
-       private List<Category> categories;
-
-       @Override
-       public void addCategory (final Category category) {
-               // Add the category
-               this.categories.add(category);
-       }
-
-       @Override
-       public void addProduct (final Product product) {
-               // Is the product available?
-               if (product.getProductAvailability()) {
-                       // Add it
-                       this.availableProducts.add(product);
-               }
-       }
-
-       @Override
-       public List<Category> getAllCategories () throws FacesException {
-               // Return it
-               // TODO Find something better here to prevent warning
-               return Collections.unmodifiableList(this.categories);
-       }
-
-       @Override
-       public List<Category> getAllCategoriesParent () throws FaceletException {
-               // Get regular list
-               List<Category> list = new LinkedList<>(this.getAllCategories());
-
-               // Return it
-               return list;
-       }
-
-       @Override
-       public List<Product> getAvailableProducts () throws FacesException {
-               // Return it
-               // TODO Find something better here to prevent warning
-               return Collections.unmodifiableList(this.availableProducts);
-       }
-
-       /**
-        * Initialization of this bean
-        */
-       @PostConstruct
-       public void init () {
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N
-
-                       // Get all categories
-                       this.categories = categoryBean.getAllCategories();
-
-                       // Try to lookup the bean
-                       ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N
-
-                       // Get available products list
-                       this.availableProducts = productBean.getAvailableProducts();
-               } catch (final NamingException e) {
-                       // Continued to throw
-                       throw new FacesException(e);
-               }
-       }
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebController.java b/src/java/org/mxchange/pizzaapplication/beans/shop/ShopWebController.java
deleted file mode 100644 (file)
index 24a51d5..0000000
+++ /dev/null
@@ -1,73 +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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.shop;
-
-import java.io.Serializable;
-import java.util.List;
-import javax.faces.view.facelets.FaceletException;
-import org.mxchange.jshopcore.model.category.Category;
-import org.mxchange.jshopcore.model.product.Product;
-
-/**
- * An interface for the shop
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface ShopWebController extends Serializable {
-
-       /**
-        * Adds given category to the "cached" instance
-        * <p>
-        * @param category Category instance
-        */
-       void addCategory (final Category category);
-
-       /**
-        * Adds given product to the "cached" instance
-        * <p>
-        * @param product Product instance
-        */
-       void addProduct (final Product product);
-
-       /**
-        * Some "getter" for a linked list of all categories
-        * <p>
-        * @return All categories
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
-        */
-       List<Category> getAllCategories () throws FaceletException;
-
-       /**
-        * Some "getter" for a linked list of all categories including "Has no
-        * parent" fake category.
-        * <p>
-        * @return All categories
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
-        */
-       List<Category> getAllCategoriesParent () throws FaceletException;
-
-       /**
-        * Some "getter" for a linked list of only available products
-        * <p>
-        * @return Only available products
-        * <p>
-        * @throws javax.faces.view.facelets.FaceletException If anything went wrong
-        */
-       List<Product> getAvailableProducts () throws FaceletException;
-}
index 62a2019ab270ab66096bb58364328c9164c13351..8149afdb8cef3e4784f6cd505470f5e94e4443f7 100644 (file)
@@ -4,7 +4,7 @@
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets">
 
-       <h:selectOneMenu class="select" id="productCategory" value="#{admin_product.productCategory}" required="true" requiredMessage="#{msg.ADMIN_CATEGORY_MUST_BE_SELECTED}" converter="category">
+       <h:selectOneMenu class="select" id="productCategory" value="#{adminProductController.productCategory}" required="true" requiredMessage="#{msg.ADMIN_CATEGORY_MUST_BE_SELECTED}" converter="category">
                <f:selectItems value="#{controller.allCategories}" var="cat" itemValue="#{cat}" itemLabel="#{cat.categoryTitle}" />
        </h:selectOneMenu>
 </ui:composition>
index 97cf68c88f3cbfaedb92c7baa1d0073ae44898f3..ea8fc2a1367548fd13c962f709f7ea6e5c2de5cd 100644 (file)
@@ -16,7 +16,7 @@
                <ui:define name="content">
                        <div class="para">
                                <h:form id="form">
-                                       <h:dataTable id="product_table" var="product" value="#{admin_product.allProducts}" styleClass="table" summary="#{msg.TABLE_SUMMARY_ADMIN_PRODUCTS}">
+                                       <h:dataTable id="product_table" var="product" value="#{adminProductController.allProducts}" styleClass="table" summary="#{msg.TABLE_SUMMARY_ADMIN_PRODUCTS}">
                                                <h:column>
                                                        <f:facet name="header">Produktnummer:</f:facet>
                                                        #{product.productId}:<h:selectBooleanCheckbox class="input" value="true" />
@@ -45,8 +45,8 @@
 
                                        <div  class="table_footer">
                                                <h:commandButton class="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
-                                               <h:commandButton class="submit" type="submit" id="edit" action="#{admin_product.editProduct(product)}" value="#{msg.ADMIN_BUTTON_EDIT_ENTRIES}" />
-                                               <h:commandButton class="delete" type="submit" id="delete" action="#{admin_category.deleteProduct(product)}" value="#{msg.ADMIN_BUTTON_DELETE_ENTRIES}" />
+                                               <h:commandButton class="submit" type="submit" id="edit" action="#{adminProductController.editProduct(product)}" value="#{msg.ADMIN_BUTTON_EDIT_ENTRIES}" />
+                                               <h:commandButton class="delete" type="submit" id="delete" action="#{adminProductController.deleteProduct(product)}" value="#{msg.ADMIN_BUTTON_DELETE_ENTRIES}" />
                                        </div>
                                </h:form>
                        </div>
                                                                </div>
 
                                                                <div class="table_right">
-                                                                       <h:selectOneListbox required="true" id="available" value="#{admin_product.productAvailability}" size="1" class="select">
+                                                                       <h:selectOneListbox required="true" id="available" value="#{adminProductController.productAvailability}" size="1" class="select">
                                                                                <f:selectItem itemValue="true" itemLabel="#{msg.YES}" />
                                                                                <f:selectItem itemValue="false" itemLabel="#{msg.NO}" />
                                                                        </h:selectOneListbox>
 
                                                <div class="table_footer">
                                                        <h:commandButton class="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
-                                                       <h:commandButton class="submit" type="submit" id="add" action="#{admin_product.addProduct()}" value="#{msg.ADMIN_BUTTON_ADD_PRODUCT}" />
+                                                       <h:commandButton class="submit" type="submit" id="add" action="#{adminProductController.addProduct()}" value="#{msg.ADMIN_BUTTON_ADD_PRODUCT}" />
                                                </div>
                                        </div>
                                </h:form>