]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java
Continued:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / checkout / CheckoutWebBean.java
index 3de6f0eab6987cb717694b7e1bf2648adadcafff..c85fdb0de378b66142eb260c004d3342202747d0 100644 (file)
@@ -16,7 +16,6 @@
  */
 package org.mxchange.pizzaapplication.beans.checkout;
 
-import java.text.MessageFormat;
 import java.util.List;
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -34,13 +33,13 @@ import javax.jms.Session;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import org.mxchange.jcoreee.beans.BaseFrameworkBean;
 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
@@ -49,7 +48,7 @@ import org.mxchange.pizzaapplication.beans.customer.CustomerWebController;
  */
 @Named ("checkoutController")
 @SessionScoped
-public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebController {
+public class CheckoutWebBean implements CheckoutWebController {
 
        /**
         * Serial number
@@ -70,7 +69,7 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon
         * Queue instance
         */
        private Queue queue;
-
+       
        /**
         * Session instance
         */
@@ -81,6 +80,11 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon
         */
        private ObjectMessage message;
 
+       /**
+        * Customer instance
+        */
+       private Customer customer;
+
        ////////////////////// Bean injections ///////////////////////
        /**
         * Basket bean
@@ -94,10 +98,16 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon
        @Inject
        private CustomerWebController customerController;
 
+       /**
+        * Receipt bean
+        */
+       @Inject
+       private ReceiptWebController receiptController;
+
        @Override
        public String doCheckout () {
                // Trace message
-               this.getLogger().logTrace("doCheckout: CALLED!");
+               //this.getLogger().logTrace("doCheckout: CALLED!");
 
                // Are the beans set?
                if (null == this.basketController) {
@@ -111,33 +121,33 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon
                // 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!");
+                       //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!");
+                       //this.getLogger().logTrace("doCheckout: basket is empty, returning empty_basket ... - EXIT!");
 
                        // Nothing to order
                        return "empty_basket"; //NOI18N
                }
 
                // Create customer instance
-               Customer customer = this.customerController.createInstance();
+               this.setCustomer(this.customerController.createCustomerInstance());
 
                // Debug message
-               this.getLogger().logDebug(MessageFormat.format("doCheckout: customer={0}", customer));
+               //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));
+               //this.getLogger().logTrace(MessageFormat.format("doCheckout: list={0}", list));
 
                // Construct container
                WrapableCheckout wrapper = new CheckoutWrapper();
-               wrapper.setCustomer(customer);
+               wrapper.setCustomer(this.getCustomer());
                wrapper.setList(list);
 
                try {
@@ -155,15 +165,25 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon
                // 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;
+       }
+
        @PostConstruct
        public void init () {
-               // Call super init for getting resource bundle
-               super.genericInit();
-
                try {
                        // Get initial context
                        Context context = new InitialContext();