From 8c7a54133e38ac34cf88cc073174ae368aeab3b8 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 16 Sep 2015 12:05:08 +0200 Subject: [PATCH] =?utf8?q?Continiued:=20-=20moved=20creating=20of=20Custom?= =?utf8?q?er=20instance=20to=20proper=20bean=20-=20renamed=20that=20bean?= =?utf8?q?=20to=20reflect=20its=20purpose=20better=20-=20added=20a=20lot?= =?utf8?q?=20logger=20messages=20-=20updated=20jars=20Signed-off-by:Roland?= =?utf8?q?=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcoreee.jar | Bin 18445 -> 18795 bytes lib/jshop-core.jar | Bin 29515 -> 29515 bytes lib/jshop-ee-lib.jar | Bin 7070 -> 7069 bytes .../beans/basket/BasketWebBean.java | 139 ++++++++++- .../beans/checkout/CheckoutWebBean.java | 233 +++--------------- .../beans/checkout/CheckoutWebController.java | 155 ------------ .../beans/customer/CustomerWebBean.java | 38 ++- .../beans/customer/CustomerWebController.java | 15 ++ .../generic/gender_selection_box.tpl | 2 +- .../templates/guest/guest_personal_data.tpl | 20 +- .../guest/guest_registration_form.tpl | 4 +- 11 files changed, 222 insertions(+), 384 deletions(-) diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 20252ca040b5e56afe2e392067112c8f883da4a8..32a615bb007b46294addca4ea2c1ef2ab8f6eaba 100644 GIT binary patch delta 1316 zcmaJ>?MqW(6hHUg&AZJl^ZjM1TjrY6+}7M&nYlY(MmkCD4e5nu4VkPBa!L`k{1OyI z)+0qh1|b9mQmCsh(Z`~1{Q*LeK@fe2pz>SiIrsLWAKZBE@4WoZ@0{ndv+L8sms^5m zpik1701N=Rlb)Lvr?i9+ye)C>T`j?PCkIv|cnAlD0O2)ZH{olcgYdrSVIg}7>lcmW ze?@=5E3;|Qq~-gyxI*ZaA{-YkNI#@aXhfF7V>Jdn&Z1{oS#h+Qa4M$(8cg7VMkC13 z#2-7j+bn}y29FG0_CX#tCex#%@v{PSFq^&fsOq^#;<41YJDENeOX8Cg+);usCZast zCP3xTL@JXw6F;07PmCnvN-CAk#4?F=YFvPV=vZtrcFr9i8*z8{hLP>#`qdlivjSa& zT{J|Cb_!q|jc3%B0w~S~UhLYi7-#%99D8dxFO@+#+oi9s@R^|n{AMVC&1NWsA~OV_ zPJkw6x0kYeayff!oX^Vm!mukyPz5H)N81blB3STXA=y}q@nW=17%f38#iPS7w!%yW zdOkz}QSW*V!ZS2PsKh5P0PrIIf}Ret)u)_G|*3awRq4>M!)To zjtqbOCEALGT=Nq(a@rSC$&cDzQiP3$f_(ef!;rdADiDxlK)XOSf{i=CX;ULs@QjI_FAkf>_WG{0r5oRzv5pG!TAH{}S9H&x@HtaJQ@ z;5^RiK@50>%?#x|v2V182hrBssB|L3-^b5Q|URB%d5_*)Ioz*h!-19rh~9h}f4 zynqJH8tl;^hz0F9UWg^JO+O;-#aH?{r3ze_F#?{D2`vydp%S*4un#N=!stp`cuR9( z-dLV;lC(r0ErSQwDdSrit;w3~EcxH7 z>|pbGzSw+qWJ%=<8>l}$UC;mu8dk-^_&QyWXCivuI`~234oB=Mx8k!zRP0sGE^dl# z?-zAEYeyMZ>^S3hJH^ZZk+x0iRgAH(fdTH(kH5L-bEJo`vbp9wv@AIq+hQ7bnvuH=Me9 z;^Tx0AZ%oVO}H=}_mvtVIFWWU`CUV5qFDzJ7TZJ)2AI4Ss>AhuH=oXxw&XjloE}OS q|II9=M%yWs_&5Ll+ZVnunk}qnljQYoA_nnW%!5M%wa#O4QT+@4+~58H diff --git a/lib/jshop-core.jar b/lib/jshop-core.jar index eda325ad96c4276316490de4a45cd21f95ecefb3..4a925a98e00a79fc5b0c6700114d4cd5499d74b2 100644 GIT binary patch delta 559 zcmY+=yGuf07zXfj(K53#qK2>wScDaI$f&f4u4F{f#n3@S!Z=>i)GkAW1dY{T9}!Ws z^e3F6w#Fb4oYJAe7T4&qL`&y+om#%%_q-SQ&Pf;fbdfhK&WRd5$LTok)|WC^1jUyc zJQvh^wiV~6MLk&)Zw2Rqg&l~M|903ZZ$mG`kAWItqJ+d+hIH&m(3ciRK~5M4jpDG1 z;u706Fj?*vV7|gh_89Uavd)+xb9En7e{QI+LjBFWLv?qDkqmV{=}@;?A9?uQ|3mZd zgLcYYwj5>6NVlQ-)+f#UPCcwTv>fNqvbe|0qsZ!e_jz8A2P-eG6MEaaCq}zD z?+x|${nyCMB-_+K#auFd^o1;;m{yA_Wr0ah2%4B2=)?6gFbj%-MR2S(oWX(8br}?b z3qT4jfy2-o$cDDSbT|s`!V%E6u>&qQwn1$~273`7c#U{~Jxb{+>PHebDfu^PGE+*u eG3uSgXyGg7#pFtS4cy1qL34tN$pozz65&6OdeV{r delta 559 zcmY+=%`3xk90%~<)0mm3#6g~Fq#=Hp%trE<=@&869G0Z5-=1w_4$@MNIPgspx%d;7 zxH+n=m6JI*%w<=3xX8ut{n^Ro`})2=5B2^1vPC{yc0T&vBA+Vl)e)a$-Ff zwEI&#&QG&;vKHO~&IL2u7c2kmuv6ZKUXC9JHNs>GnY9h;*`Z)4EslY_Faesx5skE4 z?37@td{uxi6)v*R_#z_fYjb42{)6h7#)c}?-%LrWuXfdv!R|*r>K4lb55EV0X#U-5 zr`%)9QZ@`1o&+cP-o6i%Y-Tc}O z_4mBj$gEklX@82jRr=@)RYozZ6*bEIQ=kxNW~zSx*GvB#DEb${k=AephDui_CP2XvJPG&9$=4Bx{7*{giT7`O`6P=Qh$tk cXE9p%imhRCIlckz;y%!tpkgXP>xD$<53talJ^%m! diff --git a/lib/jshop-ee-lib.jar b/lib/jshop-ee-lib.jar index d3501cbe030e16157805399001c1e3c1908f669b..1a0b0d99011926ed373a8b88e79e160666f7792d 100644 GIT binary patch delta 472 zcmbPdKG&Qlz?+$ci-CcIfnjsPL>^71O$igtr!xWB7ZgC`CruzZS(Z^BMENnAf~ZzT zTM%`G(FH_tF&Tp>dnQW|RmJ20q$V*NOb+1YKrwt0vlB>x3$r7T+T6};&BVJo!NC3S zy@+RT85tPfPCm~X%gDP~kL@8NNP!?nCKHIR;ramP=kdsZ`8|9uz;u})6En!XDiKSd znWiN+f|K0wrabSU4sta`;Tvli~r1oCJ#Ga{)y(CLiG7n7oHe z942EUCBu}+1C&viyn#(%@;V;4%zB_qJs(g;esX|->f{G}Y#==fps=~;5x~8WiGcxx fof!~dNn@rUSVICo|Ku=XL9nI{X#uuu5s)GPqi&M& delta 445 zcmbPhKF^#dz?+$ci-CcIf#I0nL>^71qka?3r!xWB7ZgC`CruzZS(Z^BMENnAf~ZzT zTM%`G(FH_tF&Tp>dnQW|RmJ20q$V*NOx_^Q#f30>60;LX+J)H>NNsLswr1iz=4ar3 z&tc1icZ>`S? allItems () { + // Trace message + this.getLogger().logTrace("allItems: CALLED!"); + // Deligate to basket instance - return this.basket.getAll(); + List 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 @@ -140,12 +170,24 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl // Caculate item's price Float totalPrice = (this.getCurrentItem().getProduct().getPrice() * this.getCurrentItem().getAmount()); + // 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; @@ -155,12 +197,18 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl totalPrice = (item.getProduct().getPrice() * item.getAmount()); } + // 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; @@ -173,12 +221,24 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl } } + // 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 @@ -192,6 +252,9 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl } } + // Trace message + this.getLogger().logTrace(MessageFormat.format("changeItem: targetPage={0} - EXIT!", targetPage)); + // Return page return targetPage; } @@ -225,19 +288,37 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl @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 ((item.isProductType()) && (item.getProduct().equals(product))) { + if (null == item) { + // item is null + throw new NullPointerException("item is null"); + } else if ((item.isProductType()) && (item.getProduct().equals(product))) { // Found it itemAmount = item.getAmount(); break; } } + // Trace message + this.getLogger().logTrace(MessageFormat.format("getItemAmount: itemAmount={0} - EXIT!", itemAmount)); + // Return it return itemAmount; } @@ -274,6 +355,9 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl @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 @@ -283,24 +367,39 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl // 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 @@ -312,7 +411,7 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl // Get type switch (item.getItemType()) { case "product": // Sellable product //NOI18N - assert(item.getProduct() instanceof Product) : MessageFormat.format("item {0} has no product instance set.", item); //NOI18N + assert (item.getProduct() instanceof Product) : MessageFormat.format("item {0} has no product instance set.", item); //NOI18N // Get title lastItem = item.getProduct().getTitle(); @@ -323,6 +422,9 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl } } + // Trace message + this.getLogger().logTrace(MessageFormat.format("outputLastAddedItem: lastItem={0} - EXIT!", lastItem)); + // Return it return lastItem; } @@ -345,6 +447,9 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl * @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 @@ -357,11 +462,20 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl // Create fake instance AddableBasketItem fake = new BasketItem(product); + // Debug message + this.getLogger().logDebug(MessageFormat.format("getItemFromProduct: fake={0}", fake)); + // Get all items List 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 @@ -376,6 +490,9 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl } } + // 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/checkout/CheckoutWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java index d36c2595..3de6f0ea 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.beans.checkout; +import java.text.MessageFormat; import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -33,14 +34,13 @@ import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jcore.model.contact.gender.Gender; import org.mxchange.jcoreee.beans.BaseFrameworkBean; import org.mxchange.jshopcore.model.basket.AddableBasketItem; import org.mxchange.jshopcore.model.customer.Customer; -import org.mxchange.jshopcore.model.customer.ShopCustomer; 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; /** * Checkout controller @@ -88,85 +88,53 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon @Inject private BasketWebController basketController; - /////////////////////// Properties ///////////////////// /** - * Gender + * Customer bean */ - private Gender gender; - - /** - * First name - */ - private String firstName; - - /** - * Family name - */ - private String familyName; - - /** - * Company name - */ - private String companyName; - - /** - * Street - */ - private String street; - - /** - * House number - */ - private Long houseNumber; - - /** - * ZIP code - */ - private Long zipCode; - - /** - * City - */ - private String city; - - /** - * Phone number - */ - private String phoneNumber; - - /** - * Fax number - */ - private String faxNumber; - - /** - * Cellphone number - */ - private String cellphoneNumber; + @Inject + private CustomerWebController customerController; @Override public String doCheckout () { - // Is the bean set? + // 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.isRequiredPersonalDataSet()) { + 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 - Customer customer = this.createCustomer(); + Customer customer = this.customerController.createInstance(); + + // Debug message + this.getLogger().logDebug(MessageFormat.format("doCheckout: customer={0}", customer)); // Get ordered list List list = this.basketController.allItems(); + // Debug message + this.getLogger().logTrace(MessageFormat.format("doCheckout: list={0}", list)); + // Construct container WrapableCheckout wrapper = new CheckoutWrapper(); wrapper.setCustomer(customer); @@ -191,116 +159,6 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon return "checkout_done"; //NOI18N } - @Override - public String getCellphoneNumber () { - return this.cellphoneNumber; - } - - @Override - public void setCellphoneNumber (final String cellphoneNumber) { - this.cellphoneNumber = cellphoneNumber; - } - - @Override - public String getCity () { - return this.city; - } - - @Override - public void setCity (final String city) { - this.city = city; - } - - @Override - public String getCompanyName () { - return this.companyName; - } - - @Override - public void setCompanyName (final String companyName) { - this.companyName = companyName; - } - - @Override - public String getFamilyName () { - return this.familyName; - } - - @Override - public void setFamilyName (final String familyName) { - this.familyName = familyName; - } - - @Override - public String getFaxNumber () { - return this.faxNumber; - } - - @Override - public void setFaxNumber (final String 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 Long getHouseNumber () { - return this.houseNumber; - } - - @Override - public void setHouseNumber (final Long houseNumber) { - this.houseNumber = houseNumber; - } - - @Override - public String getPhoneNumber () { - return this.phoneNumber; - } - - @Override - public void setPhoneNumber (final String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - @Override - public String getStreet () { - return this.street; - } - - @Override - public void setStreet (final String street) { - this.street = street; - } - - @Override - public Long getZipCode () { - return this.zipCode; - } - - @Override - public void setZipCode (final Long zipCode) { - this.zipCode = zipCode; - } - @PostConstruct public void init () { // Call super init for getting resource bundle @@ -324,6 +182,9 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon // And message producer this.messageProducer = session.createProducer(queue); + + // Finally the message instance itself + this.message = this.session.createObjectMessage(); } catch (final NamingException | JMSException e) { // Continued to throw throw new FacesException(e); @@ -345,40 +206,4 @@ public class CheckoutWebBean extends BaseFrameworkBean implements CheckoutWebCon throw new FacesException(ex); } } - - /** - * Creates a full customer instance - * - * @return Customer instance - */ - private Customer createCustomer () { - // Required personal data must be set - assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N - - // Create new customer instance - Customer customer = new ShopCustomer(); - customer.setGender(this.getGender()); - customer.setFirstName(this.getFirstName()); - customer.setFamilyName(this.getFamilyName()); - customer.setCompanyName(this.getCompanyName()); - customer.setStreet(this.getStreet()); - customer.setHouseNumber(this.getHouseNumber()); - customer.setZipCode(this.getZipCode()); - customer.setCity(this.getCity()); - customer.setPhoneNumber(this.getPhoneNumber()); - customer.setFaxNumber(this.getFaxNumber()); - customer.setCellphoneNumber(this.getCellphoneNumber()); - - // Return it - return customer; - } - - /** - * Checks if the required personal data is set - * - * @return Whether the required personal data is set - */ - private 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/checkout/CheckoutWebController.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebController.java index cd2f6efa..4e30f29f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/CheckoutWebController.java @@ -17,7 +17,6 @@ package org.mxchange.pizzaapplication.beans.checkout; import java.io.Serializable; -import org.mxchange.jcore.model.contact.gender.Gender; /** * An interface for the shop @@ -31,158 +30,4 @@ public interface CheckoutWebController extends Serializable { * @return Page redirection target */ public String doCheckout (); - - /** - * Getter for cellphone number - * - * @return Cellphone number - */ - public String getCellphoneNumber (); - - /** - * Setter for cellphone number - * - * @param cellphoneNumber Cellphone number - */ - public void setCellphoneNumber (final String cellphoneNumber); - - /** - * Getter for city - * - * @return Cellphone number - */ - public String getCity (); - - /** - * Setter for city - * - * @param city City - */ - public void setCity (final String city); - - /** - * Getter for company name - * - * @return City - */ - public String getCompanyName (); - - /** - * Setter for company name - * - * @param companyName Company name - */ - public void setCompanyName (final String companyName); - - /** - * Getter for family name - * - * @return Company name - */ - public String getFamilyName (); - - /** - * Setter for family name - * - * @param familyName Family name - */ - public void setFamilyName (final String familyName); - - /** - * Getter for fax number - * - * @return Family name - */ - public String getFaxNumber (); - - /** - * Setter for fax number - * - * @param faxNumber First name - */ - public void setFaxNumber (final String faxNumber); - - /** - * Getter for first name - * - * @return First name - */ - public String getFirstName (); - - /** - * Setter for first name - * - * @param firstName Gender - */ - public void setFirstName (final String firstName); - - /** - * Getter for gender - * - * @return Gender - */ - public Gender getGender (); - - /** - * Setter for gender - * - * @param gender Gender - */ - public void setGender (final Gender gender); - - /** - * Getter for house number - * - * @return House number - */ - public Long getHouseNumber (); - - /** - * Setter for house number - * - * @param houseNumber House number - */ - public void setHouseNumber (final Long houseNumber); - - /** - * Getter for phone number - * - * @return Phone number - */ - public String getPhoneNumber (); - - /** - * Setter for phone number - * - * @param phoneNumber Phone number - */ - public void setPhoneNumber (final String phoneNumber); - - /** - * Getter for street - * - * @return Street - */ - public String getStreet (); - - /** - * Setter for street - * - * @param street Street - */ - public void setStreet (final String street); - - /** - * Getter for ZIP code - * - * @return ZIP code - */ - public Long getZipCode (); - - /** - * Setter for ZIP code - * - * @param zipCode ZIP code - */ - public void setZipCode (final Long zipCode); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java index 6adf22c0..bc76943a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.beans.customer; +import java.text.MessageFormat; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @@ -24,14 +25,16 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcore.model.contact.gender.Gender; import org.mxchange.jcoreee.beans.BaseFrameworkBean; +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 * * @author Roland Haeder */ -@Named("customer") +@Named("customerController") @SessionScoped public class CustomerWebBean extends BaseFrameworkBean implements CustomerWebController { /** @@ -131,6 +134,34 @@ public class CustomerWebBean extends BaseFrameworkBean implements CustomerWebCon this.customerBean = (CustomerSessionBeanRemote) context.lookup("ejb/stateless-customer"); } + @Override + public Customer createInstance () { + // 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(); + customer.setGender(this.getGender()); + customer.setFirstName(this.getFirstName()); + customer.setFamilyName(this.getFamilyName()); + customer.setCompanyName(this.getCompanyName()); + customer.setStreet(this.getStreet()); + customer.setHouseNumber(this.getHouseNumber()); + customer.setZipCode(this.getZipCode()); + customer.setCity(this.getCity()); + customer.setPhoneNumber(this.getPhoneNumber()); + customer.setFaxNumber(this.getFaxNumber()); + customer.setCellphoneNumber(this.getCellphoneNumber()); + + // Trace message + this.getLogger().logTrace(MessageFormat.format("createInstance: customer={0} - EXIT!", customer)); + + // Return it + return customer; + } + @PostConstruct public void init () throws RuntimeException { // Call super init first @@ -266,4 +297,9 @@ public class CustomerWebBean extends BaseFrameworkBean implements CustomerWebCon public void setCellphoneNumber (final String cellphoneNumber) { this.cellphoneNumber = cellphoneNumber; } + + @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 index 691211b5..e912d05d 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebController.java @@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.beans.customer; import java.io.Serializable; import org.mxchange.jcore.model.contact.gender.Gender; +import org.mxchange.jshopcore.model.customer.Customer; /** * An interface for customer beans @@ -26,6 +27,13 @@ import org.mxchange.jcore.model.contact.gender.Gender; */ public interface CustomerWebController extends Serializable { + /** + * Creates an instance from all properties + * + * @return A Customer instance + */ + public Customer createInstance (); + /** * Gender of the contact * @@ -207,4 +215,11 @@ public interface CustomerWebController extends Serializable { * @param cellphoneNumber the cellphoneNumber to set */ public void setCellphoneNumber (final String cellphoneNumber); + + /** + * Checks whether all required personal data is set + * + * @return Whether the required personal data is set + */ + public boolean isRequiredPersonalDataSet (); } diff --git a/web/WEB-INF/templates/generic/gender_selection_box.tpl b/web/WEB-INF/templates/generic/gender_selection_box.tpl index 2a5dd7dc..422ace8d 100644 --- a/web/WEB-INF/templates/generic/gender_selection_box.tpl +++ b/web/WEB-INF/templates/generic/gender_selection_box.tpl @@ -5,7 +5,7 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> - + diff --git a/web/WEB-INF/templates/guest/guest_personal_data.tpl b/web/WEB-INF/templates/guest/guest_personal_data.tpl index a3f11e83..7c780dd3 100644 --- a/web/WEB-INF/templates/guest/guest_personal_data.tpl +++ b/web/WEB-INF/templates/guest/guest_personal_data.tpl @@ -31,7 +31,7 @@
- +
@@ -43,7 +43,7 @@
- +
@@ -57,7 +57,7 @@
- +
@@ -71,7 +71,7 @@
- +
@@ -85,7 +85,7 @@
- +
@@ -99,7 +99,7 @@
- +
@@ -111,7 +111,7 @@
- +
@@ -125,7 +125,7 @@
- +
@@ -137,7 +137,7 @@
- +
@@ -149,7 +149,7 @@
- +
diff --git a/web/WEB-INF/templates/guest/guest_registration_form.tpl b/web/WEB-INF/templates/guest/guest_registration_form.tpl index a2844782..3bed98b6 100644 --- a/web/WEB-INF/templates/guest/guest_registration_form.tpl +++ b/web/WEB-INF/templates/guest/guest_registration_form.tpl @@ -24,7 +24,7 @@
- +
@@ -36,7 +36,7 @@
- +
-- 2.39.5