]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Rewrites:
authorRoland Häder <roland@mxchange.org>
Wed, 19 Apr 2017 17:45:02 +0000 (19:45 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Apr 2017 17:45:45 +0000 (19:45 +0200)
- use beanHelper where possible, lesser class attributes to handle
- set checkout-wrapper in event than customer only
- let's hope, this is working ... (template)

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java
src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/customer/PizzaAdminCustomerWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java
src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java
web/customer/checkout_done.xhtml

index 315678b50c5a8e76541a9adad4156b39f166a38b..00e948cd96d5bf78cf03edfc092590b38d85cd0c 100644 (file)
@@ -35,7 +35,6 @@ import javax.jms.Session;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import org.mxchange.jcustomercore.model.customer.Customer;
 import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
 import org.mxchange.jshopcore.events.ShopCheckoutCompletedEvent;
 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
@@ -45,6 +44,7 @@ import org.mxchange.pizzaapplication.beans.BasePizzaController;
 import org.mxchange.pizzaapplication.beans.basket.PizzaBasketWebSessionController;
 import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController;
 import org.mxchange.pizzaapplication.beans.customer.PizzaCustomerWebSessionController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestController;
 import org.mxchange.pizzaapplication.beans.receipt.PizzaReceiptWebSessionController;
 
 /**
@@ -68,6 +68,12 @@ public class PizzaCheckoutWebSessionBean extends BasePizzaController implements
        @Inject
        private PizzaBasketWebSessionController basketController;
 
+       /**
+        * Bean helper instance
+        */
+       @Inject
+       private PizzaWebRequestController beanHelper;
+
        /**
         * Event fired when a checkout was completed by the user
         */
@@ -86,11 +92,6 @@ public class PizzaCheckoutWebSessionBean extends BasePizzaController implements
        @Inject
        private PizzaContactWebSessionController contactController;
 
-       /**
-        * Customer instance
-        */
-       private Customer customer;
-
        /**
         * Customer bean
         */
@@ -167,7 +168,7 @@ public class PizzaCheckoutWebSessionBean extends BasePizzaController implements
 
                // Construct container
                WrapableCheckout wrapper = new CheckoutWrapper();
-               wrapper.setCustomer(this.getCustomer());
+               wrapper.setCustomer(this.beanHelper.getCustomer());
                wrapper.setList(list);
 
                try {
@@ -183,22 +184,12 @@ public class PizzaCheckoutWebSessionBean extends BasePizzaController implements
                }
 
                // Fire event
-               this.checkoutCompletedEvent.fire(new ShopCheckoutCompletedEvent(this.getCustomer()));
+               this.checkoutCompletedEvent.fire(new ShopCheckoutCompletedEvent(wrapper));
 
                // 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
         */
index b255ce4870120626a47214121d7d445df01037ba..6a94e9602f8a546f572d10bcc4d4efa0634e99ea 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.pizzaapplication.beans.checkout;
 
 import java.io.Serializable;
 import javax.ejb.Local;
-import org.mxchange.jcustomercore.model.customer.Customer;
 
 /**
  * An interface for the shop
@@ -35,18 +34,4 @@ public interface PizzaCheckoutWebSessionController extends Serializable {
         */
        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);
-
 }
index 79dbf6d1fcf36be1f4900ed8e8f81f55739029d6..16d8873820924cfc48e72f319e589b91c39f0201 100644 (file)
@@ -56,7 +56,7 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp
        private static final long serialVersionUID = 57_637_182_796_370L;
 
        /**
-        * Admin helper instance
+        * Bean helper instance
         */
        @Inject
        private PizzaWebRequestController beanHelper;
index 2c9f1e5417003a5e9aa9488883b2d289f9f2baa9..4b8d98872b015dc86fcebe49270290dc04e922dc 100644 (file)
@@ -80,7 +80,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
        private AdminContactSessionBeanRemote adminContactBean;
 
        /**
-        * Admin helper instance
+        * Bean helper instance
         */
        @Inject
        private PizzaWebRequestController beanHelper;
index 5c92a13c085b68f426d146460724c70161c5106a..e867da036ae774534b461924abb20dd650d166ae 100644 (file)
@@ -67,7 +67,7 @@ public class PizzaAdminCustomerWebRequestBean extends BasePizzaController implem
        private PizzaAdminCustomerSessionBeanRemote adminCustomerBean;
 
        /**
-        * Admin helper instance
+        * Bean helper instance
         */
        @Inject
        private PizzaWebRequestController adminHelper;
index f71033594400d7e8b277455eb64cfd9ad80d10ca..f02eeb044d221856d7317b67c2a91b50cc2d1baa 100644 (file)
  */
 package org.mxchange.pizzaapplication.beans.receipt;
 
-import java.text.MessageFormat;
 import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
 import javax.faces.FacesException;
+import javax.inject.Inject;
 import javax.inject.Named;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import org.mxchange.jcustomercore.model.customer.Customer;
-import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
 import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
 import org.mxchange.pizzaapplication.beans.BasePizzaController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestController;
 
 /**
  * Checkout controller
@@ -44,9 +42,10 @@ public class PizzaReceiptWebSessionBean extends BasePizzaController implements P
        private static final long serialVersionUID = 95_723_834_783_478_781L;
 
        /**
-        * Customer instance
+        * Bean helper instance
         */
-       private Customer customer;
+       @Inject
+       private PizzaWebRequestController beanHelper;
 
        /**
         * Remote bean instance
@@ -69,48 +68,9 @@ public class PizzaReceiptWebSessionBean extends BasePizzaController implements P
                }
        }
 
-       @Override
-       public void afterCheckoutCompleted (@Observes final ObservableCheckoutCompletedEvent event) {
-               // Is all set?
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null");
-               } else if (event.getCustomer() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.customer is null");
-               } else if (event.getCustomer().getCustomerId() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("event.customer.customerId is null");
-               } else if (event.getCustomer().getCustomerId() < 0) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("event.customer.customerId={0} is not valid.", event.getCustomer().getCustomerId()));
-               }
-
-               // Set customer
-               this.setCustomer(event.getCustomer());
-       }
-
        @Override
        public String fetchAccessKey () {
-               return this.receiptBean.fetchAccessKey(this.getCustomer());
-       }
-
-       /**
-        * Getter for customer instance
-        * <p>
-        * @return Customer instance
-        */
-       private Customer getCustomer () {
-               return this.customer;
-       }
-
-       /**
-        * Setter for customer instance
-        * <p>
-        * @param customer Customer instance
-        */
-       private void setCustomer (final Customer customer) {
-               this.customer = customer;
+               return this.receiptBean.fetchAccessKey(this.beanHelper.getCustomer());
        }
 
 }
index cf1b7dc892cdc3292a399acf06b240044974bc2d..904c629889ff4986ba5756345a360f98828c5597 100644 (file)
@@ -17,7 +17,6 @@
 package org.mxchange.pizzaapplication.beans.receipt;
 
 import java.io.Serializable;
-import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
 
 /**
  * An interface for the shop
@@ -26,13 +25,6 @@ import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
  */
 public interface PizzaReceiptWebSessionController extends Serializable {
 
-       /**
-        * Observes events being fired when a checkout is completed by user
-        * <p>
-        * @param event Event being fired
-        */
-       void afterCheckoutCompleted (final ObservableCheckoutCompletedEvent event);
-
        /**
         * Fetches last access key for given customer instance
         * <p>
index f27c950b3a85424f7d3a4fc3a9f5b13e1ca4cc20..4673aa0bf322c12d2fd119b20ef4b5c9bf8c5903 100644 (file)
@@ -91,7 +91,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements
        private final AdminUserSessionBeanRemote adminUserBean;
 
        /**
-        * Admin helper instance
+        * Bean helper instance
         */
        @Inject
        private PizzaWebRequestController beanHelper;
index 22fdce63c48695f1cd2e97d93a93d2d726aa7df9..098e59d3e6f679166b661515a8c3acc9a3d4c3ef 100644 (file)
@@ -21,7 +21,7 @@
                        <!-- @TODO Move this to i18n bundle //-->
                        Rechnung abrufen:
                        <h:link class="receipt_link" id="receipt" outcome="pdf" value="#{msg.LINK_OPEN_RECEIPT}" target="_blank">
-                               <f:param name="customer" value="#{checkoutController.customer.customerId}" />
+                               <f:param name="customer" value="#{beanHelper.customer.customerId}" />
                                <f:param name="key" value="#{receiptController.fetchAccessKey()}" />
                        </h:link>
                </ui:define>