*/
package org.mxchange.pizzaapplication.beans.checkout;
-import java.text.MessageFormat;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
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
*/
@Named ("checkoutController")
@SessionScoped
-public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebController {
+public class CheckoutWebBean implements CheckoutWebController {
/**
* Serial number
* Queue instance
*/
private Queue queue;
-
+
/**
* Session instance
*/
*/
private ObjectMessage message;
+ /**
+ * Customer instance
+ */
+ private Customer customer;
+
////////////////////// Bean injections ///////////////////////
/**
* Basket bean
@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) {
// 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 {
// 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();