From: Roland Häder Date: Wed, 19 Apr 2017 17:45:02 +0000 (+0200) Subject: Rewrites: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0612bbfe061c00a4ee3ed9359c44c5d3ed46a4ac;p=pizzaservice-war.git Rewrites: - 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 --- diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java index 315678b5..00e948cd 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java @@ -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 */ diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java index b255ce48..6a94e960 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionController.java @@ -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 - *

- * @return Customer instance - */ - Customer getCustomer (); - - /** - * Setter for customer instance - *

- * @param customer Customer instance - */ - void setCustomer (final Customer customer); - } diff --git a/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java index 79dbf6d1..16d88738 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/confirmlink/PizzaConfirmationLinkWebRequestBean.java @@ -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; diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index 2c9f1e54..4b8d9887 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java @@ -80,7 +80,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme private AdminContactSessionBeanRemote adminContactBean; /** - * Admin helper instance + * Bean helper instance */ @Inject private PizzaWebRequestController beanHelper; diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaAdminCustomerWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaAdminCustomerWebRequestBean.java index 5c92a13c..e867da03 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaAdminCustomerWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaAdminCustomerWebRequestBean.java @@ -67,7 +67,7 @@ public class PizzaAdminCustomerWebRequestBean extends BasePizzaController implem private PizzaAdminCustomerSessionBeanRemote adminCustomerBean; /** - * Admin helper instance + * Bean helper instance */ @Inject private PizzaWebRequestController adminHelper; diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java index f7103359..f02eeb04 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java @@ -16,18 +16,16 @@ */ 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 - *

- * @return Customer instance - */ - private Customer getCustomer () { - return this.customer; - } - - /** - * Setter for customer instance - *

- * @param customer Customer instance - */ - private void setCustomer (final Customer customer) { - this.customer = customer; + return this.receiptBean.fetchAccessKey(this.beanHelper.getCustomer()); } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java index cf1b7dc8..904c6298 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java @@ -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 - *

- * @param event Event being fired - */ - void afterCheckoutCompleted (final ObservableCheckoutCompletedEvent event); - /** * Fetches last access key for given customer instance *

diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java index f27c950b..4673aa0b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java @@ -91,7 +91,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements private final AdminUserSessionBeanRemote adminUserBean; /** - * Admin helper instance + * Bean helper instance */ @Inject private PizzaWebRequestController beanHelper; diff --git a/web/customer/checkout_done.xhtml b/web/customer/checkout_done.xhtml index 22fdce63..098e59d3 100644 --- a/web/customer/checkout_done.xhtml +++ b/web/customer/checkout_done.xhtml @@ -21,7 +21,7 @@ Rechnung abrufen: - +