From 9f582d6e8055fdfb9b8f2b96d710eb4e44e4d8fa Mon Sep 17 00:00:00 2001 From: Ethanell Date: Thu, 30 Jun 2022 22:15:08 +0200 Subject: [PATCH] Formatting and logout fix --- build/web/WEB-INF/classes/DAO/Customer.class | Bin 3742 -> 3742 bytes .../WEB-INF/classes/DAO/DiscountCode.class | Bin 1002 -> 1002 bytes .../WEB-INF/classes/DAO/HibernateUtil.class | Bin 1286 -> 1286 bytes .../WEB-INF/classes/DAO/MagasinHelper.class | Bin 15615 -> 16103 bytes .../WEB-INF/classes/DAO/Manufacturer.class | Bin 3019 -> 3019 bytes .../web/WEB-INF/classes/DAO/MicroMarket.class | Bin 1514 -> 1514 bytes build/web/WEB-INF/classes/DAO/Product.class | Bin 2635 -> 2635 bytes .../web/WEB-INF/classes/DAO/ProductCode.class | Bin 1279 -> 1279 bytes .../WEB-INF/classes/DAO/PurchaseOrder.class | Bin 2653 -> 2653 bytes .../classes/controller/BddController$1.class | Bin 828 -> 828 bytes .../classes/controller/BddController.class | Bin 15396 -> 15377 bytes build/web/WEB-INF/classes/jsp/achats.jsp | 38 +- build/web/WEB-INF/classes/jsp/confirm.jsp | 2 +- build/web/WEB-INF/classes/jsp/detail.jsp | 16 +- .../WEB-INF/classes/jsp/form_inscription.jsp | 38 +- build/web/WEB-INF/classes/jsp/header.jsp | 2 +- build/web/WEB-INF/classes/jsp/index.jsp | 4 +- build/web/WEB-INF/classes/jsp/login.jsp | 30 +- build/web/WEB-INF/classes/jsp/menu.jsp | 2 +- build/web/WEB-INF/classes/jsp/recherche.jsp | 6 +- build/web/WEB-INF/classes/jsp/resultat.jsp | 58 +- build/web/WEB-INF/classes/service/User.class | Bin 1253 -> 1253 bytes build/web/WEB-INF/jsp/achats.jsp | 38 +- build/web/WEB-INF/jsp/confirm.jsp | 2 +- build/web/WEB-INF/jsp/detail.jsp | 16 +- build/web/WEB-INF/jsp/error.jsp | 18 - build/web/WEB-INF/jsp/form_inscription.jsp | 38 +- build/web/WEB-INF/jsp/header.jsp | 2 +- build/web/WEB-INF/jsp/index.jsp | 4 +- build/web/WEB-INF/jsp/login.jsp | 30 +- build/web/WEB-INF/jsp/menu.jsp | 2 +- build/web/WEB-INF/jsp/recherche.jsp | 6 +- build/web/WEB-INF/jsp/resultat.jsp | 58 +- src/java/DAO/Customer.java | 109 +- src/java/DAO/DiscountCode.java | 26 +- src/java/DAO/HibernateUtil.java | 10 +- src/java/DAO/MagasinHelper.java | 1064 +++++++++-------- src/java/DAO/Manufacturer.java | 90 +- src/java/DAO/MicroMarket.java | 41 +- src/java/DAO/Product.java | 68 +- src/java/DAO/ProductCode.java | 34 +- src/java/DAO/PurchaseOrder.java | 68 +- src/java/Exceptions/InvalidParameter.java | 1 + src/java/controller/BddController.java | 768 ++++++------ src/java/service/User.java | 23 +- web/WEB-INF/jsp/achats.jsp | 38 +- web/WEB-INF/jsp/confirm.jsp | 2 +- web/WEB-INF/jsp/deconnexion.jsp | 18 - web/WEB-INF/jsp/detail.jsp | 16 +- web/WEB-INF/jsp/error.jsp | 18 - web/WEB-INF/jsp/form_inscription.jsp | 38 +- web/WEB-INF/jsp/header.jsp | 2 +- web/WEB-INF/jsp/index.jsp | 4 +- web/WEB-INF/jsp/login.jsp | 30 +- .../WEB-INF/jsp/logout.jsp | 4 +- web/WEB-INF/jsp/menu.jsp | 2 +- web/WEB-INF/jsp/recherche.jsp | 6 +- web/WEB-INF/jsp/resultat.jsp | 58 +- 58 files changed, 1479 insertions(+), 1469 deletions(-) delete mode 100644 build/web/WEB-INF/jsp/error.jsp delete mode 100644 web/WEB-INF/jsp/deconnexion.jsp delete mode 100644 web/WEB-INF/jsp/error.jsp rename build/web/WEB-INF/jsp/deconnexion.jsp => web/WEB-INF/jsp/logout.jsp (79%) diff --git a/build/web/WEB-INF/classes/DAO/Customer.class b/build/web/WEB-INF/classes/DAO/Customer.class index e02a52182d5d9da477b7ef332534f73458f3a941..584c30e2151915665906c0a2a6fc69a725caa7d5 100644 GIT binary patch delta 379 zcmW;Fy-EW?6o%n5;H=r*WJJV-XqFiNG8%Q_&qh+LAfgaN`xFWmiXsXk3JMWYXeEd{ zXt{#5MG6aTENpDO2Jb-d0{mw9s`K!|NrEKkJaL|-F3QDzzkcVn-aL*0a%qqR6{wGb z*lCxFz#(7>I1C)2JdIM3#;|d!P+31aU*QC*NmLb7Q>dm<&7e}Ks?b?%juvU2B3hso z3aLRgopisly7|7Jk~|_#OSAG@*lWu nxSo;x8hm59l~FnrS^b%j`cxFOBNV$g*}9PY0okL??nKW&_P0!j delta 379 zcmW;FIZFdk6o%n*!4oqxnGq3{h*9H~>w4od(SQLZg&SxaL9tLo3>J!o3*u5}BM5W* z5v)_Bu+YZB#@63pX(#vt{O)ZId=D?2I1^{;Pt0j*ppM9E)o)yA&R}$rL){cm54BJ> zO59|7fqlS!-~e!t(v(9Yv4&`bhV^seGaN-VhH4y@LX}4~foc-f6sl>gkY=brCEPO2 z(lQlw-1s8q%=i7I5CbQJ@MLeM0A5ibPYlQtXW(Oyn7o21fKeK# jN^~+Gvj(d?11p2VWNT(OMrE+rbfB0zP)uX;5oR?2w`dOt delta 89 zcmaFG{)&CWA4XOI1{Mav$&5^noFYJ$C<7;h*ko^}0A6t*PXfr3WZ+|vn!JK3fKe8x jN^~+Gvj(do11p2lWNT(OMisEwbfB09P)u|35oR?2y>bsG diff --git a/build/web/WEB-INF/classes/DAO/HibernateUtil.class b/build/web/WEB-INF/classes/DAO/HibernateUtil.class index 1aadeb95c74b8a71fe5154874b738b85d98b319c..ba0f90727576ad1b67b7e16e4c6ec18c0cb2657b 100644 GIT binary patch delta 45 zcmZqUYUA3V&cY}-S%bxzQF(F-ONyu@g8+j(gD`_Mg9w8xgD!&{gBgRugD!&tgBgR;?+D^JFV!geIZ5g}5KV4TN(_Mf0E(VA5hJi)kW=riO%|VvdPgE>|$3Rf52(^awRt~m9O zUpDxV~NeuCh~0cX^v`ZddCooAiLQ*DmuC29c0N zf}ex{2{)23gufrkP6|Ik5>iPRPQpzj1W8CGAxJ_h2{->E!Ee^M+(7}ipv~sAQHr4d zO!U#{W6-nEZ%4lqeJojbVPvD`sX+NE(Rh_AM-{BASl3YNsSTRsawBJZeMeju>U#=u zA@Wq@V&v(_GmvM}_kHwTM&EPrXOmEhRmMB#@LERSbLe~C-+ixa+szG$3QcB7R4CyA z5*CuMh=d18s3Ku03Cl=$h=f%nRFklrgcT&LBB2_86$#ZO)czyEZtEjcqdOhpLx9{azM5i_B zAA9l+5l90Qo~E@(~j`$wW>eA7>&bn8-;ca*BzZWFn`S$mf4gB(h_F??e}O4C#&N zU!i}4eg^$t=>JCl7X3T)v*_p0e?b2c{Ve)9^t0&a(0}#xp`LucQ%L>|`FG^=$QKlC zjAG42iZk5x=3=FoE0k`+lx;56ICGiuSWjhLMqNx@ZLap@MAzr~E4+KWSQ$~kw# z=T)9RJvQXugg*j56@Mgt8vZT#>G&D=WAL-^Gx0~`kHOEvAA_HTKNi2xo5_i;p_$~M z=A!1KPC%WAdJpPkW>UaRrl1uwlWEMPkeL)QlVWBvjhPfPlWELk7BlJPzV4RBZ+*MJ zGAxDDler(c47mb%uAhjanyTFz?oiKJZ&S| zCbcx1)z)l5+9sdbu0iH$-Dq}blzCovm}hjSd6p?OXo7i86WO21{(Q63ec5Zg@w>sj zpYpWbXnWE2p}mH70PS@pnuEH*9MwqkmTotP5D#-oZz$g!(cSFNV1J%D<~sPsd#AJ0 z7do8}5kKN;k8`yrIGvN6&MB_;6Hez-PUkcFI?d@cayp-LI$v-)r@7KbPUkeI)5z(Z z;dBPNqkV>08@A)BxJZ+mqe#x@TkP-Y_6NHCiEhu)?axXwzi62G51su=XaCiG=6|X* z|JPFUn>Lx>wcT3nv=`~1`9p`ydA(^a=$Mt>Xa5WKzq6ORS@9c8sar5G*=6>vZGP6- zFj;$*TH2OsYr_>|BjmHKlw@0Ln7vlHwv8s)Xw9(gHP1$BzP(NhZIqVSwpzyiI`%i& z&TeIb&mHaGFRYelck`#DIp;{fP);m4-N@-qPET@rlj9?&4>@t<#FLXiP9iyd$>~Q< ze{u$plR!=)IesrE;9W(^fRH{IeJFYg`f&6S=t1;U^pWVJ&@<6Tqo<+YjD8DxI(jDh zX!P5f^x*@W^<&eo`8He@7;33+|8Pm8RS+_a6^7eM_^uP+vyfjk*VQAL?tU`Dj VqD}$Oe|D~Oo%{DX-_Q5DzSq9HQGoKpB@s=BC~dMHhq{0*z8 z3e-m>>ZOV5tuof@l_Ca{*sNru3_!_2$>sYzlzfyh%21TSC__+&qFf#* z>3%|doYi^j9`QTkx98@lE%gjXDnc5GGzw`n(ilZFR)s1?8LvuRt7?r?4eLf-?=#av z{$Qt~pr+BCn`^oOsTAo(q;jMwNK>h3IyKFurrBsWQPW&%x|N!00^#F?W}yn98esv# z?FcmpcOWc6Sc#UpKoLAOnA-y+l zs{*g2XR~)HUN5{1ygqm#yiB|-yncAOc-eRZ@N)6O|9gH_dTU!2orR<6+r#;~2ze+{ z0n+72S0G)9G#sgjj3dZ65~Y}oSCMfv8H>p{j*J=p*Gos*WWT?6mY>rr=(m-iO++h2 zD^r4%tGi7`o1z?>r7<>5V{N*wWxd?y_!l$6zN&Yj6{GAscY~|~;TD8>2$cxc2=fsZ zAk-o(M5sZiMOcDRVOc)ZXGhTIyZL&V5^XtOtyIYBHPG(SVDlPpt2Dt@lV**|ZLOxT zS8MBiLTFN}OwRZ`-i2DfIJKW|49yL+4QLOeZA9CIwpqEhMT2aIuCuL(+vxJ6y3ram znY~4})0g+16udU4`v$L#J&m%9M9};zntr zyGmuO*STvL&so96Da;QpjvJ3K0pWUt5`;+zHz?vtRp`q2dYUR-xvJe{)v#`KGou%0 zTDZuT`^Iqa@4?MMxf!Jbpe^S{)YT#0g}4-P8R81Wl_a}ISG)T(+pX43ZjCBfZ*%wi#e=8+2PA>Q ACIA2c diff --git a/build/web/WEB-INF/classes/DAO/Manufacturer.class b/build/web/WEB-INF/classes/DAO/Manufacturer.class index e8c8db0092624a12df192f78cc75a557a0fc473d..406e4e3e2001baa58cc87aad3a111b9b929c193f 100644 GIT binary patch delta 321 zcmW;EJxW7C6b0Zj@NSZM4@@EP#h}snI}l+KQX~+9qF`g8qM#zEXkj3QLIMUX)Iv8f zi%?QoTDXI^23KI=7ChYUobMiPmS*YaStKPymXM7!YYah&>e~e;`}70#w}LlE>KXlneyU!y-khr+TPK(FEBdavQTw6Y()zls m#oi3)J-MUZt4(M_-TuW+9_VBBR^rX0`Z#g&M1NNQPKy7IYedWd delta 321 zcmW;EJ4!=Q6ouh+;O->nUND8oH4qcy^JpZ;7(^5UKET3438*Oe02K?x!k8i{Ep!5B z5K1ab3ukc0;0P?7f{V?r{*T4Z(k%Tvi)0)TN}&^vh39C=mRS?9sDzK`wOM6NvT7K? z6h<+P5@t}vEN>2V%%cg1H7uZwMeL#;E@fyM`mK_4vI0RXyx25c=e$`}f2Xh0H`IUW zo9fGXCtLJw^()!z!LJXV?!jpxVqeVr5JTV|ooPm!)f3lc@>xd delta 117 zcmaFG{fc|TVJ22V1{MaP$ptK;lkYO=aEbzXVho%N;**7#qeUfvJV_u=ih++onn9RB z2FR10+{B#1r~uaShgpMFg@Khpb+RUl8>2c<%$8Lf$k&;?3CPz2tKnnSU^N1Y8Bexm GT@L^Z#ud&0 diff --git a/build/web/WEB-INF/classes/DAO/Product.class b/build/web/WEB-INF/classes/DAO/Product.class index a27863a22f2d9f5b58b84058588ae39ae6219872..ab23df66a8cb9436b1b3dc66667b7050cf5dcde0 100644 GIT binary patch delta 245 zcmX>ta$00V7YnNh0}F%bzdQVhZj(vx4aw5!SjMdg5^ z@<34qpr|5HUJ1xkW>95NVbBJWh74+xr?d7jYJyF&WYb{PWng8{o6N`|KDm}npV1I3 zeh4UT3KTa3i?gxsU~~kFUt!l^bp?vM0ma=IJ;7qJ92%^?KruhC+JzkYjDbLLTh>sZ qSQuDLi&LL560A0#Q-d`YC>{qE-wYH_1dIOwil+j_)4<|3T>JoC`!byX delta 245 zcmX>ta$00V7YnNx0}F%r<#=e8m0W5xnU4zvHDDDarcVl!1i^XziuzCZIW3}2a9h8iU)zke*ne9fa2j` oaT`v3#wf6OBc}#y98f$SEPfOyo&*->;?iJE1B$1E#r?SW0VIYnZ2$lO delta 241 zcmcaBa#v)-92Qn_1{Ma1$qQM$1*L&383s-USq44^IR;?{`N@A-+Eo>RqKZIKC7`G> zP*jCMl0lV0oH=72l0Rt<8;bca3@yY#c`i#b4 z@hd=abD+2dQ2acj7ytkO delta 21 ccmdnPwuf!QYbMSh22O@x1|f!!$zPZ}07zp75C8xG diff --git a/build/web/WEB-INF/classes/controller/BddController.class b/build/web/WEB-INF/classes/controller/BddController.class index 6eb574a73b790668522342af71e0ae6ce7a18dc3..e7073501ff24e0c09d8fd6e3b82bb8ba4a27df91 100644 GIT binary patch delta 2521 zcmYLL33OFO60KWVUjLW=SqMphkPyO>Ktci}$i4+cK-mWwWHWpc2q6h1`Lc$f?7QKC z;IOLfd-w_rvJA2#qJX0!(HYss8PLeUus8@-!<;kcopZapy87Pg>VEa!`Uzzd?6Xe} z944YP?owutA41E$cex-43$e(;VuiQO ze3@}xVvLT$Qbm{s}+ zQ95AYV*>~6Qo%zC)fB2L)KG|4sHqTR;jqcc5u4WIFUIqzflmw^vvAy|tvF!@Ck>pk zaN4GwIAh_gO}p`_g>yFT!DnV0=Z(kbX1iY~T(EG_rv12N<4ZF$9U+2=_^ZNK7QVLd zjnB_-4BOJXY~fqEKF-8|o&HxOzfMx%W&ig;3C<4@;Z9|ZDo!J74Jv%+tVh6J-$_?( z_Ww?@=iCa)z(prTH}8E}<9qzg!rwK1z*SAh=>$j@Wfi`W2vzR!ap_sgH_?f;@=>kMW!1alh>M z1W%oEcU%x@2D4^A8CSTI1N}7zNH;jRmI}mE&DOI)O{Y(A%~GY=#kK_RDHxHZIS5Y; z_1J=<;!N)Z&DxCJd71g%>`YIww=k=)NVD4*_1MCK5nfMmCs`-9U_%`8Z1w*p#29ME zfzP7{`Q>}_EDqCLg~K&hZm2oQ zK(c{GoT51u*PIO@@%};(?d%AOc5a5W2yU#o2{*M+VKS2DB!@<$(&-wS5ai-?i<=qi z3(lm_VSdeV)u{;W@7ID`I_Y68m5W=+UEtP^H>@_=ILpK0+qad-I(O`q+Bv7lBY{0j zlJRK=3NiNH|IeK#V=|!=L}zuD);R8G=e-t0S)&N z%B92fsh}+_Q62K9y3Vke88HcDQ6fcBLyDm!N~RP_qf}~3jp-F?x+J#L^#TP@bBd!D z&YajZ*8uX9hbY216C0cKoU9!MQ3pCF*0|?$^ckI(k$BMsy7(-L2w!BaMV!?|$X=pg z>PpqAo2YfCW}vP2?ai2*dHCd#lh*XJ4O%PTI5d3q!{`W4Ca7#Z}NZ0sop$mMzsj1lm|NCaXWEN6c5LANFg zZVEv##URw#+&ICR+-Q_5f`Sl98d1*eMzdWp6o6O?L@j4Z%E9XODOA|Q<=`VEZFL}* zP?WkL#p#pkbEV0ubaJDa<8Hjj-HMc)R5;pDZL|~i)$R;(p%Ya>XIa(7>Dy$btGoET zO!4U9+;6hX-A9!BN-X^-3H_ZFO;@@Hl8r$WiNRD2Lwp_5`uLR&7ZQ&MWy|+s6djcl zJB!hD1-W!nPVNr!WaIgeKLLbcENaST6XXw|DT>e<#TW)JhGRT(F#(e>5%UC>VKUZW z3bvpGdoUG;P>Rc#h6=nTwST&l>={yTXG+1G#Zf&mo8vHt8(=P{V;=XweC~~fJP?c6 zgT*`+Z*vira0wiqg{54EWxNjW@CR7I+wm^%#A+_bO7>wDAHiDR(B|{G?RrV_1`5VT zs*X*PoXyk>Tjb|w8+DQ!*b6)5-SWwMwTp(zZOoVcIH?jv*drg(k9_r8)kl*9Lh-Rs l92AN}LUC9qjtIq3p*SWK$A#jQP@E8olk%5x#wlsN>34igM#2C9 delta 2556 zcmYLL2Xs|c7Crl(hGUSTOM&Qw!3skH(E~$mO2&%{FPU+e!f=HV3L_OpDdbofZBrsL4CE^0 zS;$uiQ*>XUorc*7Ja#498yBq=mkNLEO(P;67r zC)*_o;l`}g!UUUoW4yvdg)&7o3TKGnc1rb<}3Q%FbfnGT3BS$_$OH|4#aC%V&P8;OU?f4 z#@I3B8w$%5-8Jhs6_%TEg@LyWylr5mKo#CmSY^{;tTxBjSXisD&Ze2jvanuZgN==N z*TyDnR(Q{hTNJh`Y%|u|ZS25Kgm!*B2$$mS1uSk8J7XBA~*MkzAoXBwJOrtO-#afN8y{D{NpxS#pAeMc< zk?J|O1G8|!N!9K9T+;Xl{%PS`jjOn(=~Fre((e4Sio)Fdw1G0wbOJS+j?-rv*Kq^n z>k-z%cN*X0rlvD=*1|1~+xWrRtK*~Y;9nYdaZlq8e$@C0*DT!E_!%{zWanwWIi%Q@jfjIQhP>HlpA8EV%4PtpSUlz56Q4$~aYbu`!IdYbD;a0AT^xsm1w zj?^5*(V81`jOJL5b83T|1pdKIEL_ptl$$vTA&Jk#qgLY&PSBia%H!%=8e<+y%$QP7 zNnT7wn&u>K0L%Jn>YibW=F-7MF~`o5-Ez3D4AMNx?pEYq283{ zJcz0aNGCsPLow9WnGu~HJc@keN7Sf!i)zx&f#~SE!H>ijp#q1K4?mPkwE>>f%?NuFJKl8#9SJT6*L6rX(+DJ za9pR6()**>ML8T!x!jEMIGgf$0FC8AG>%76@nffL#1nBYeMzS!1T#BF=e@4DQ0`wQ zTW$%WT!QdO5ET-{B8MXtNRsQNBfX4FxkviZY>cKk$ftQ2OY<>> z7GOFp!aQ2yEo-`obKVfyWg`2g$SxPz6(ak#7&bsZ2g7cYp;S3V|<0!O!WMvLwK!Km?M8b}pvO3kV}W zDUv_xIEASP8%B@|(G-qIs*5OUf*ASi#8MB$IhkqRfCM>}NI^()eoK2TD3uh_#I_~H zqLnBoI0su+1hu6Aw4*Szmy=I9U0SUS=p=TXDGr&=wN}f5vc!9~#L|sgpu01t^~#`U z$wn`#hu+ixeY`2@{e7xl5Rn1mY><3XhR{(ArIV7}WxPZ;FpPf0a7l0kEQ~}bMj;Y8 zNWf^cMlL!cPuP4}6<|EZVhRee0OPPsR;y8jEhxrbl;99baS;=61!eMqaLY|!&OY$4 zMg`aJi%A@VN>0LLZi6Y@2UEEprt?tD;9OMk1k7YNUg7DO#d9&6mtqdD#a!NiS9v?; z^G+=0Jy^(IEaD?r;_cObA$OKOh4d+;Pa%COZ&zEqCI63BQZ`o6^H?o!+6EeiH8cWi zsYK=zv5wqWFE7Kp-tdfgwAv~X+eBi!NbC@aog%SIB=(4eS0vsSiE5G9ClVjXADR8m IxQ?6u3!~aZqyPW_ diff --git a/build/web/WEB-INF/classes/jsp/achats.jsp b/build/web/WEB-INF/classes/jsp/achats.jsp index f285c3c..c71013a 100644 --- a/build/web/WEB-INF/classes/jsp/achats.jsp +++ b/build/web/WEB-INF/classes/jsp/achats.jsp @@ -8,27 +8,27 @@ <%@include file="header.jsp" %> - - + +

Achats du client n°<%=request.getParameter("customerId")%>

- - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
${cli.orderNum}${cli.customerId}${cli.productId}${cli.quantity}${cli.shippingCost}${cli.salesDate}${cli.shippingDate}${cli.freightCompany}
${cli.orderNum}${cli.customerId}${cli.productId}${cli.quantity}${cli.shippingCost}${cli.salesDate}${cli.shippingDate}${cli.freightCompany}
- - + + diff --git a/build/web/WEB-INF/classes/jsp/confirm.jsp b/build/web/WEB-INF/classes/jsp/confirm.jsp index 5233c5f..7440c6f 100644 --- a/build/web/WEB-INF/classes/jsp/confirm.jsp +++ b/build/web/WEB-INF/classes/jsp/confirm.jsp @@ -13,7 +13,7 @@ <%@include file="header.jsp" %> - +

${error != null ? error : confirm}

diff --git a/build/web/WEB-INF/classes/jsp/detail.jsp b/build/web/WEB-INF/classes/jsp/detail.jsp index 73ea3a9..ded1bf0 100644 --- a/build/web/WEB-INF/classes/jsp/detail.jsp +++ b/build/web/WEB-INF/classes/jsp/detail.jsp @@ -8,7 +8,7 @@ <%@include file="header.jsp" %> - + @@ -106,12 +106,12 @@ checked id="isavailable" /> - - checked id="notavailable" /> -

-

- - + + checked id="notavailable" /> +

+

+ +

@@ -185,7 +185,7 @@

- + diff --git a/build/web/WEB-INF/classes/jsp/form_inscription.jsp b/build/web/WEB-INF/classes/jsp/form_inscription.jsp index 4dbc842..3f86767 100644 --- a/build/web/WEB-INF/classes/jsp/form_inscription.jsp +++ b/build/web/WEB-INF/classes/jsp/form_inscription.jsp @@ -14,40 +14,40 @@ Bienvenue ${user.login} - +

- - + +

- - + +

- - + +

- +

- - - + + +

diff --git a/build/web/WEB-INF/classes/jsp/header.jsp b/build/web/WEB-INF/classes/jsp/header.jsp index 8b7579e..b8ff3d7 100644 --- a/build/web/WEB-INF/classes/jsp/header.jsp +++ b/build/web/WEB-INF/classes/jsp/header.jsp @@ -15,7 +15,7 @@
- + diff --git a/build/web/WEB-INF/classes/jsp/index.jsp b/build/web/WEB-INF/classes/jsp/index.jsp index 5ebe295..d74394b 100644 --- a/build/web/WEB-INF/classes/jsp/index.jsp +++ b/build/web/WEB-INF/classes/jsp/index.jsp @@ -2,5 +2,5 @@ -<% response.sendRedirect("menu.htm"); %> - +<% response.sendRedirect("menu.htm");%> + diff --git a/build/web/WEB-INF/classes/jsp/login.jsp b/build/web/WEB-INF/classes/jsp/login.jsp index bc11518..db636fd 100644 --- a/build/web/WEB-INF/classes/jsp/login.jsp +++ b/build/web/WEB-INF/classes/jsp/login.jsp @@ -13,20 +13,20 @@ - - - - - - - - - - - - - -
Utilisateur :
Mot de passe :
-
+ + + + + + + + + + + + + +
Utilisateur :
Mot de passe :
+ diff --git a/build/web/WEB-INF/classes/jsp/menu.jsp b/build/web/WEB-INF/classes/jsp/menu.jsp index ed702d7..855bcfe 100644 --- a/build/web/WEB-INF/classes/jsp/menu.jsp +++ b/build/web/WEB-INF/classes/jsp/menu.jsp @@ -14,7 +14,7 @@ <%@include file="header.jsp" %>

choisissez une opération dans la liste suivante

- +

diff --git a/build/web/WEB-INF/classes/jsp/recherche.jsp b/build/web/WEB-INF/classes/jsp/recherche.jsp index bc110dd..90e4c66 100644 --- a/build/web/WEB-INF/classes/jsp/recherche.jsp +++ b/build/web/WEB-INF/classes/jsp/recherche.jsp @@ -13,14 +13,14 @@ <%@include file="header.jsp" %> - + -

+

- + diff --git a/build/web/WEB-INF/classes/jsp/resultat.jsp b/build/web/WEB-INF/classes/jsp/resultat.jsp index bb96101..b76af35 100644 --- a/build/web/WEB-INF/classes/jsp/resultat.jsp +++ b/build/web/WEB-INF/classes/jsp/resultat.jsp @@ -14,7 +14,7 @@ <%@include file="header.jsp" %> - +

${error}

@@ -27,37 +27,37 @@ - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + +
${col}${col}
-
- - - -
-
${v} -
- - - -
-
+
+ + + +
+
${v} +
+ + + +
+
diff --git a/build/web/WEB-INF/classes/service/User.class b/build/web/WEB-INF/classes/service/User.class index d335310b4def6d0c802826ff279e423959162aaa..0cd6d9a9706d0d76750527e06a4fb44190b650ce 100644 GIT binary patch delta 121 zcmaFL`IK{mCKIFBWGyChPALW!25AOC2ARoOOb)CH3>*xKlh-r(@hStwRTwxKR2jq= z)F*Q>#|ml!MYMn-+6;UQIzT*xylh-r(@yY?kI~8h8j~xS0~oa@pJcXW)n{O3Fqq8E;>Kt^If%uU)f~vT Vm^_8Wjaz_$kwKAxfq{uZ2>_(s5)1$U diff --git a/build/web/WEB-INF/jsp/achats.jsp b/build/web/WEB-INF/jsp/achats.jsp index f285c3c..c71013a 100644 --- a/build/web/WEB-INF/jsp/achats.jsp +++ b/build/web/WEB-INF/jsp/achats.jsp @@ -8,27 +8,27 @@ <%@include file="header.jsp" %> - - + +

Achats du client n°<%=request.getParameter("customerId")%>

- - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
${cli.orderNum}${cli.customerId}${cli.productId}${cli.quantity}${cli.shippingCost}${cli.salesDate}${cli.shippingDate}${cli.freightCompany}
${cli.orderNum}${cli.customerId}${cli.productId}${cli.quantity}${cli.shippingCost}${cli.salesDate}${cli.shippingDate}${cli.freightCompany}
- - + + diff --git a/build/web/WEB-INF/jsp/confirm.jsp b/build/web/WEB-INF/jsp/confirm.jsp index 5233c5f..7440c6f 100644 --- a/build/web/WEB-INF/jsp/confirm.jsp +++ b/build/web/WEB-INF/jsp/confirm.jsp @@ -13,7 +13,7 @@ <%@include file="header.jsp" %> - +

${error != null ? error : confirm}

diff --git a/build/web/WEB-INF/jsp/detail.jsp b/build/web/WEB-INF/jsp/detail.jsp index 73ea3a9..ded1bf0 100644 --- a/build/web/WEB-INF/jsp/detail.jsp +++ b/build/web/WEB-INF/jsp/detail.jsp @@ -8,7 +8,7 @@ <%@include file="header.jsp" %> - + @@ -106,12 +106,12 @@ checked id="isavailable" /> - - checked id="notavailable" /> -

-

- - + + checked id="notavailable" /> +

+

+ +

@@ -185,7 +185,7 @@

- + diff --git a/build/web/WEB-INF/jsp/error.jsp b/build/web/WEB-INF/jsp/error.jsp deleted file mode 100644 index 14af0fd..0000000 --- a/build/web/WEB-INF/jsp/error.jsp +++ /dev/null @@ -1,18 +0,0 @@ -<%-- - Document : error - Created on : 4 mars 2018, 20:54:56 - Author : faycal ---%> - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - Erreur - - - <%@include file="header.jsp" %> -

${erreur}

- - diff --git a/build/web/WEB-INF/jsp/form_inscription.jsp b/build/web/WEB-INF/jsp/form_inscription.jsp index 4dbc842..3f86767 100644 --- a/build/web/WEB-INF/jsp/form_inscription.jsp +++ b/build/web/WEB-INF/jsp/form_inscription.jsp @@ -14,40 +14,40 @@ Bienvenue ${user.login} - +

- - + +

- - + +

- - + +

- +

- - - + + +

diff --git a/build/web/WEB-INF/jsp/header.jsp b/build/web/WEB-INF/jsp/header.jsp index 8b7579e..b8ff3d7 100644 --- a/build/web/WEB-INF/jsp/header.jsp +++ b/build/web/WEB-INF/jsp/header.jsp @@ -15,7 +15,7 @@
- + diff --git a/build/web/WEB-INF/jsp/index.jsp b/build/web/WEB-INF/jsp/index.jsp index 5ebe295..d74394b 100644 --- a/build/web/WEB-INF/jsp/index.jsp +++ b/build/web/WEB-INF/jsp/index.jsp @@ -2,5 +2,5 @@ -<% response.sendRedirect("menu.htm"); %> - +<% response.sendRedirect("menu.htm");%> + diff --git a/build/web/WEB-INF/jsp/login.jsp b/build/web/WEB-INF/jsp/login.jsp index bc11518..db636fd 100644 --- a/build/web/WEB-INF/jsp/login.jsp +++ b/build/web/WEB-INF/jsp/login.jsp @@ -13,20 +13,20 @@ - - - - - - - - - - - - - -
Utilisateur :
Mot de passe :
-
+ + + + + + + + + + + + + +
Utilisateur :
Mot de passe :
+ diff --git a/build/web/WEB-INF/jsp/menu.jsp b/build/web/WEB-INF/jsp/menu.jsp index ed702d7..855bcfe 100644 --- a/build/web/WEB-INF/jsp/menu.jsp +++ b/build/web/WEB-INF/jsp/menu.jsp @@ -14,7 +14,7 @@ <%@include file="header.jsp" %>

choisissez une opération dans la liste suivante

- +

diff --git a/build/web/WEB-INF/jsp/recherche.jsp b/build/web/WEB-INF/jsp/recherche.jsp index bc110dd..90e4c66 100644 --- a/build/web/WEB-INF/jsp/recherche.jsp +++ b/build/web/WEB-INF/jsp/recherche.jsp @@ -13,14 +13,14 @@ <%@include file="header.jsp" %> - + -

+

- + diff --git a/build/web/WEB-INF/jsp/resultat.jsp b/build/web/WEB-INF/jsp/resultat.jsp index bb96101..b76af35 100644 --- a/build/web/WEB-INF/jsp/resultat.jsp +++ b/build/web/WEB-INF/jsp/resultat.jsp @@ -14,7 +14,7 @@ <%@include file="header.jsp" %> - +

${error}

@@ -27,37 +27,37 @@ - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + +
${col}${col}
-
- - - -
-
${v} -
- - - -
-
+
+ + + +
+
${v} +
+ + + +
+
diff --git a/src/java/DAO/Customer.java b/src/java/DAO/Customer.java index b18c73b..dddc9e6 100644 --- a/src/java/DAO/Customer.java +++ b/src/java/DAO/Customer.java @@ -1,149 +1,152 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - - /** * Customer generated by hbm2java */ -public class Customer implements java.io.Serializable { +public class Customer implements java.io.Serializable { - - private int customerId; - private char discountCode; - private String zip; - private String name; - private String addressline1; - private String addressline2; - private String city; - private String state; - private String phone; - private String fax; - private String email; - private Integer creditLimit; + private int customerId; + private char discountCode; + private String zip; + private String name; + private String addressline1; + private String addressline2; + private String city; + private String state; + private String phone; + private String fax; + private String email; + private Integer creditLimit; public Customer() { } - public Customer(int customerId, char discountCode, String zip) { this.customerId = customerId; this.discountCode = discountCode; this.zip = zip; } - public Customer(int customerId, char discountCode,String _name, String _adress, String _phone,String _email, String _zip) { + + public Customer(int customerId, char discountCode, String _name, String _adress, String _phone, String _email, String _zip) { this.customerId = customerId; this.discountCode = discountCode; - this.name=_name; - this.addressline1=_adress; - this.phone=_phone; - this.email=_email; + this.name = _name; + this.addressline1 = _adress; + this.phone = _phone; + this.email = _email; this.zip = _zip; } - + public Customer(int customerId, char discountCode, String zip, String name, String addressline1, String addressline2, String city, String state, String phone, String fax, String email, Integer creditLimit) { - this.customerId = customerId; - this.discountCode = discountCode; - this.zip = zip; - this.name = name; - this.addressline1 = addressline1; - this.addressline2 = addressline2; - this.city = city; - this.state = state; - this.phone = phone; - this.fax = fax; - this.email = email; - this.creditLimit = creditLimit; + this.customerId = customerId; + this.discountCode = discountCode; + this.zip = zip; + this.name = name; + this.addressline1 = addressline1; + this.addressline2 = addressline2; + this.city = city; + this.state = state; + this.phone = phone; + this.fax = fax; + this.email = email; + this.creditLimit = creditLimit; } - + public int getCustomerId() { return this.customerId; } - + public void setCustomerId(int customerId) { this.customerId = customerId; } + public char getDiscountCode() { return this.discountCode; } - + public void setDiscountCode(char discountCode) { this.discountCode = discountCode; } + public String getZip() { return this.zip; } - + public void setZip(String zip) { this.zip = zip; } + public String getName() { return this.name; } - + public void setName(String name) { this.name = name; } + public String getAddressline1() { return this.addressline1; } - + public void setAddressline1(String addressline1) { this.addressline1 = addressline1; } + public String getAddressline2() { return this.addressline2; } - + public void setAddressline2(String addressline2) { this.addressline2 = addressline2; } + public String getCity() { return this.city; } - + public void setCity(String city) { this.city = city; } + public String getState() { return this.state; } - + public void setState(String state) { this.state = state; } + public String getPhone() { return this.phone; } - + public void setPhone(String phone) { this.phone = phone; } + public String getFax() { return this.fax; } - + public void setFax(String fax) { this.fax = fax; } + public String getEmail() { return this.email; } - + public void setEmail(String email) { this.email = email; } + public Integer getCreditLimit() { return this.creditLimit; } - + public void setCreditLimit(Integer creditLimit) { this.creditLimit = creditLimit; } - - - } - - diff --git a/src/java/DAO/DiscountCode.java b/src/java/DAO/DiscountCode.java index ee0f264..e640e3a 100644 --- a/src/java/DAO/DiscountCode.java +++ b/src/java/DAO/DiscountCode.java @@ -1,48 +1,42 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - import java.math.BigDecimal; /** * DiscountCode generated by hbm2java */ -public class DiscountCode implements java.io.Serializable { +public class DiscountCode implements java.io.Serializable { - - private char discountCode; - private BigDecimal rate; + private char discountCode; + private BigDecimal rate; public DiscountCode() { } - public DiscountCode(char discountCode) { this.discountCode = discountCode; } + public DiscountCode(char discountCode, BigDecimal rate) { - this.discountCode = discountCode; - this.rate = rate; + this.discountCode = discountCode; + this.rate = rate; } - + public char getDiscountCode() { return this.discountCode; } - + public void setDiscountCode(char discountCode) { this.discountCode = discountCode; } + public BigDecimal getRate() { return this.rate; } - + public void setRate(BigDecimal rate) { this.rate = rate; } - - - } - - diff --git a/src/java/DAO/HibernateUtil.java b/src/java/DAO/HibernateUtil.java index 9eff547..7fded0c 100644 --- a/src/java/DAO/HibernateUtil.java +++ b/src/java/DAO/HibernateUtil.java @@ -8,7 +8,6 @@ package DAO; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.SessionFactory; - /** * Hibernate Utility class with a convenient method to get Session Factory * object. @@ -18,21 +17,20 @@ import org.hibernate.SessionFactory; public class HibernateUtil { private static final SessionFactory sessionFactory; - + static { try { // Create the SessionFactory from standard (hibernate.cfg.xml) // config file. - sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); - - + sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); + } catch (Throwable ex) { // Log the exception. System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } - + public static SessionFactory getSessionFactory() { return sessionFactory; } diff --git a/src/java/DAO/MagasinHelper.java b/src/java/DAO/MagasinHelper.java index 75dea46..bcd10ff 100644 --- a/src/java/DAO/MagasinHelper.java +++ b/src/java/DAO/MagasinHelper.java @@ -4,6 +4,7 @@ * and open the template in the editor. */ package DAO; + import org.hibernate.*; import org.hibernate.cfg.Configuration; import java.util.*; @@ -15,650 +16,705 @@ import org.hibernate.exception.ConstraintViolationException; * @author faycal */ public class MagasinHelper { + Session session = null; public List getColonnes() { return colonnes; } - ArrayList colonnes=new ArrayList(); + ArrayList colonnes = new ArrayList(); public MagasinHelper() { this.session = HibernateUtil.getSessionFactory().openSession(); } - - public List getProductsColums(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public List getProductsColums() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select p.productId, p.manufacturerId, p.productCode, p.purchaseCost, p.quantityOnHand, p.markup, p.available, p.description from Product p"); - resultat=q.list(); - - + + tx = session.beginTransaction(); + Query q = session.createQuery("select p.productId, p.manufacturerId, p.productCode, p.purchaseCost, p.quantityOnHand, p.markup, p.available, p.description from Product p"); + resultat = q.list(); + } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } - - public List getProducts(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public List getProducts() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from Product p"); - resultat=q.list(); - - + + tx = session.beginTransaction(); + Query q = session.createQuery("from Product p"); + resultat = q.list(); + } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } - - public Product getProduct(int id){ - Product resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public Product getProduct(int id) { + Product resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from Product p where p.productId = :_id"); + + tx = session.beginTransaction(); + Query q = session.createQuery("from Product p where p.productId = :_id"); q.setInteger("_id", id); - resultat=(Product)q.list().iterator().next(); - - + resultat = (Product) q.list().iterator().next(); + } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } - - public List getClientsColums(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public List getClientsColums() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip,b.rate from Customer a, DiscountCode b where a.discountCode=b.discountCode"); + + tx = session.beginTransaction(); + Query q = session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip,b.rate from Customer a, DiscountCode b where a.discountCode=b.discountCode"); //Query q=session.createQuery("from Customer"); - resultat=q.list(); - - + resultat = q.list(); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return resultat; -} - - public List getClients(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); - session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from Customer c"); - resultat=q.list(); - - - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - + return resultat; -} - - public List getClientsColums(String name){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public List getClients() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip,b.rate from Customer a, DiscountCode b where a.discountCode=b.discountCode and a.name like :_name"); + + tx = session.beginTransaction(); + Query q = session.createQuery("from Customer c"); + resultat = q.list(); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } + } + + return resultat; + } + + public List getClientsColums(String name) { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } + session.flush(); + + tx = session.beginTransaction(); + Query q = session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip,b.rate from Customer a, DiscountCode b where a.discountCode=b.discountCode and a.name like :_name"); //Query q=session.createQuery("from Customer"); - q.setString("_name",name); - resultat=q.list(); + q.setString("_name", name); + resultat = q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return resultat; -} - - public List getClientsColums(int _id){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + return resultat; + } + + public List getClientsColums(int _id) { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip from Customer a where a.customerId = :_id"); + + tx = session.beginTransaction(); + Query q = session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip from Customer a where a.customerId = :_id"); q.setInteger("_id", _id); - resultat=q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return resultat; -} - - public List getManufacturers(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); - session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from Manufacturer m"); - resultat=q.list(); - - + resultat = q.list(); } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } - - public List getProductCodesColums(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public List getManufacturers() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select p.prodCode, p.discountCode, p.description from ProductCode p"); - resultat=q.list(); - - + + tx = session.beginTransaction(); + Query q = session.createQuery("from Manufacturer m"); + resultat = q.list(); + } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } - - public List getProductCodes(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public List getProductCodesColums() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from ProductCode p"); - resultat=q.list(); - - + + tx = session.beginTransaction(); + Query q = session.createQuery("select p.prodCode, p.discountCode, p.description from ProductCode p"); + resultat = q.list(); + } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } - - public ProductCode getProductCode(String id){ - ProductCode resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + + public List getProductCodes() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from ProductCode p where p.prodCode = :_id"); + + tx = session.beginTransaction(); + Query q = session.createQuery("from ProductCode p"); + resultat = q.list(); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } + } + + return resultat; + } + + public ProductCode getProductCode(String id) { + ProductCode resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } + session.flush(); + + tx = session.beginTransaction(); + Query q = session.createQuery("from ProductCode p where p.prodCode = :_id"); q.setString("_id", id); - resultat=(ProductCode)q.list().iterator().next(); - - + resultat = (ProductCode) q.list().iterator().next(); + } catch (Exception e) { e.printStackTrace(); - } finally{ - if (session.isOpen())session.close(); + } finally { + if (session.isOpen()) { + session.close(); + } } return resultat; } -public List getDiscountCodesColums(){ -List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen()) - session=HibernateUtil.getSessionFactory().openSession(); + public List getDiscountCodesColums() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select dc.discountCode, dc.rate from DiscountCode dc"); - resultat=q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - - } - - return resultat; + tx = session.beginTransaction(); + Query q = session.createQuery("select dc.discountCode, dc.rate from DiscountCode dc"); + resultat = q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } -} + } -public List getDiscountCodes(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen()) - session=HibernateUtil.getSessionFactory().openSession(); + return resultat; + + } + + public List getDiscountCodes() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from DiscountCode dc"); - resultat=q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - - } - - return resultat; + tx = session.beginTransaction(); + Query q = session.createQuery(" from DiscountCode dc"); + resultat = q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } -} + } -public DiscountCode getDiscountCode(char c){ - DiscountCode resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen()) - session=HibernateUtil.getSessionFactory().openSession(); + return resultat; + + } + + public DiscountCode getDiscountCode(char c) { + DiscountCode resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from DiscountCode dc where dc.discountCode = :_id"); + + tx = session.beginTransaction(); + Query q = session.createQuery(" from DiscountCode dc where dc.discountCode = :_id"); q.setCharacter("_id", c); - resultat=(DiscountCode)q.list().iterator().next(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - - } - - return resultat; + resultat = (DiscountCode) q.list().iterator().next(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } + } -} + return resultat; -public List getMicroMarket(){ -List resultat=null; - Transaction tx=null; - try{ + } + + public List getMicroMarket() { + List resultat = null; + Transaction tx = null; + try { //if(!session.isOpen()) - session=HibernateUtil.getSessionFactory().openSession(); + session = HibernateUtil.getSessionFactory().openSession(); session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("from MicroMarket"); - resultat=q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - + + tx = session.beginTransaction(); + Query q = session.createQuery("from MicroMarket"); + resultat = q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } + } return resultat; -} -public List getZipCode(){ -List resultat=null; - Transaction tx=null; - try{ + } + + public List getZipCode() { + List resultat = null; + Transaction tx = null; + try { //if(!session.isOpen()) - session=HibernateUtil.getSessionFactory().openSession(); + session = HibernateUtil.getSessionFactory().openSession(); session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select a.zipCode from MicroMarket a"); - resultat=q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - + + tx = session.beginTransaction(); + Query q = session.createQuery("select a.zipCode from MicroMarket a"); + resultat = q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } + } return resultat; -} -public void add (Object data) { - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public void add(Object data) { + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - session.save(data); - tx.commit(); + + tx = session.beginTransaction(); + session.save(data); + tx.commit(); } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} -public void update (Object data) { - - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public void update(Object data) { + + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - session.update(data); - tx.commit(); - } - catch (Exception e) { + + tx = session.beginTransaction(); + session.update(data); + tx.commit(); + } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} -public Customer getClient(int id){ - - - Customer client=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); - session.flush(); - tx=session.beginTransaction(); - Query q=session.createQuery(" from Customer a where a.customerId =:_id"); - q.setInteger("_id", id); - client=(Customer)q.list().iterator().next(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return client; -} + } -public void deleteCustomer (int _id) { - - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + public Customer getClient(int id) { + + Customer client = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from PurchaseOrder po where po.customerId =:_id"); - q.setInteger("_id",_id); - for (Object po : q.list()) - session.delete((PurchaseOrder) po); - q=session.createQuery(" from Customer a where a.customerId =:_id"); - q.setInteger("_id",_id); - session.delete((Customer)q.list().iterator().next()); - tx.commit(); + tx = session.beginTransaction(); + Query q = session.createQuery(" from Customer a where a.customerId =:_id"); + q.setInteger("_id", id); + client = (Customer) q.list().iterator().next(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } } - catch (Exception e) { + + return client; + } + + public void deleteCustomer(int _id) { + + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } + session.flush(); + + tx = session.beginTransaction(); + Query q = session.createQuery(" from PurchaseOrder po where po.customerId =:_id"); + q.setInteger("_id", _id); + for (Object po : q.list()) { + session.delete((PurchaseOrder) po); + } + q = session.createQuery(" from Customer a where a.customerId =:_id"); + q.setInteger("_id", _id); + session.delete((Customer) q.list().iterator().next()); + tx.commit(); + } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} -public void deleteProduct (int _id) { - - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public void deleteProduct(int _id) { + + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from Product a where a.productId =:_id"); - q.setInteger("_id",_id); - session.delete((Product)q.list().iterator().next()); - tx.commit(); - } - catch (Exception e) { + + tx = session.beginTransaction(); + Query q = session.createQuery(" from Product a where a.productId =:_id"); + q.setInteger("_id", _id); + session.delete((Product) q.list().iterator().next()); + tx.commit(); + } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} -public void deletePurchase(int _id) { - - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public void deletePurchase(int _id) { + + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from PurchaseOrder a where a.orderNum =:_id"); - q.setInteger("_id",_id); - session.delete((PurchaseOrder)q.list().iterator().next()); - tx.commit(); - } - catch (Exception e) { + + tx = session.beginTransaction(); + Query q = session.createQuery(" from PurchaseOrder a where a.orderNum =:_id"); + q.setInteger("_id", _id); + session.delete((PurchaseOrder) q.list().iterator().next()); + tx.commit(); + } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} -public void deleteDiscountCode (char _id) { - - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public void deleteDiscountCode(char _id) { + + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from DiscountCode a where a.discountCode =:_id"); - q.setCharacter("_id",_id); - session.delete((DiscountCode)q.list().iterator().next()); - tx.commit(); - } - catch (Exception e) { + + tx = session.beginTransaction(); + Query q = session.createQuery(" from DiscountCode a where a.discountCode =:_id"); + q.setCharacter("_id", _id); + session.delete((DiscountCode) q.list().iterator().next()); + tx.commit(); + } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} -public void deleteProductCode(String _id) { - - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + } + + public void deleteProductCode(String _id) { + + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from ProductCode a where a.prodCode =:_id"); - q.setString("_id",_id); - session.delete((ProductCode)q.list().iterator().next()); - tx.commit(); - } - catch (Exception e) { + + tx = session.beginTransaction(); + Query q = session.createQuery(" from ProductCode a where a.prodCode =:_id"); + q.setString("_id", _id); + session.delete((ProductCode) q.list().iterator().next()); + tx.commit(); + } catch (Exception e) { e.printStackTrace(); tx.rollback(); throw e; + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); - } - -} - public List getPurchaseColums(){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); - session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select po.orderNum, po.customerId, po.productId, po.quantity, po.shippingCost, po.salesDate, po.shippingDate, po.freightCompany from PurchaseOrder po"); - resultat=(List)q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return resultat; -} + } - public PurchaseOrder getPurchase(int id){ - PurchaseOrder resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + public List getPurchaseColums() { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from PurchaseOrder p where p.orderNum = :_id"); - q.setInteger("_id", id); - resultat=(PurchaseOrder)q.list().iterator().next(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return resultat; -} - - public List getPurchases(int id){ - List resultat=null; - Transaction tx=null; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); - session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery(" from PurchaseOrder po where po.customerId = :_id"); - q.setInteger("_id", id); - resultat=q.list(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally{ - if (session.isOpen())session.close(); - } - - return resultat; -} -public int getMaxId(){ - Transaction tx=null; - int resultat=-1; - try{ - if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + tx = session.beginTransaction(); + Query q = session.createQuery("select po.orderNum, po.customerId, po.productId, po.quantity, po.shippingCost, po.salesDate, po.shippingDate, po.freightCompany from PurchaseOrder po"); + resultat = (List) q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } + } + + return resultat; + } + + public PurchaseOrder getPurchase(int id) { + PurchaseOrder resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } session.flush(); - - tx=session.beginTransaction(); - Query q=session.createQuery("select MAX(a.customerId) from Customer a"); - - resultat=(int)q.list().iterator().next(); + + tx = session.beginTransaction(); + Query q = session.createQuery(" from PurchaseOrder p where p.orderNum = :_id"); + q.setInteger("_id", id); + resultat = (PurchaseOrder) q.list().iterator().next(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } } - catch (Exception e) { - e.printStackTrace(); + + return resultat; + } + + public List getPurchases(int id) { + List resultat = null; + Transaction tx = null; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } + session.flush(); + + tx = session.beginTransaction(); + Query q = session.createQuery(" from PurchaseOrder po where po.customerId = :_id"); + q.setInteger("_id", id); + resultat = q.list(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } } - finally{ - if (session.isOpen())session.close(); + + return resultat; + } + + public int getMaxId() { + Transaction tx = null; + int resultat = -1; + try { + if (!session.isOpen()) { + session = HibernateUtil.getSessionFactory().openSession(); + } + session.flush(); + + tx = session.beginTransaction(); + Query q = session.createQuery("select MAX(a.customerId) from Customer a"); + + resultat = (int) q.list().iterator().next(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (session.isOpen()) { + session.close(); + } } - - return resultat; - -} + + return resultat; + + } } diff --git a/src/java/DAO/Manufacturer.java b/src/java/DAO/Manufacturer.java index c8ff5a5..82d8acb 100644 --- a/src/java/DAO/Manufacturer.java +++ b/src/java/DAO/Manufacturer.java @@ -1,128 +1,130 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - - /** * Manufacturer generated by hbm2java */ -public class Manufacturer implements java.io.Serializable { +public class Manufacturer implements java.io.Serializable { - - private int manufacturerId; - private String name; - private String addressline1; - private String addressline2; - private String city; - private String state; - private String zip; - private String phone; - private String fax; - private String email; - private String rep; + private int manufacturerId; + private String name; + private String addressline1; + private String addressline2; + private String city; + private String state; + private String zip; + private String phone; + private String fax; + private String email; + private String rep; public Manufacturer() { } - public Manufacturer(int manufacturerId) { this.manufacturerId = manufacturerId; } + public Manufacturer(int manufacturerId, String name, String addressline1, String addressline2, String city, String state, String zip, String phone, String fax, String email, String rep) { - this.manufacturerId = manufacturerId; - this.name = name; - this.addressline1 = addressline1; - this.addressline2 = addressline2; - this.city = city; - this.state = state; - this.zip = zip; - this.phone = phone; - this.fax = fax; - this.email = email; - this.rep = rep; + this.manufacturerId = manufacturerId; + this.name = name; + this.addressline1 = addressline1; + this.addressline2 = addressline2; + this.city = city; + this.state = state; + this.zip = zip; + this.phone = phone; + this.fax = fax; + this.email = email; + this.rep = rep; } - + public int getManufacturerId() { return this.manufacturerId; } - + public void setManufacturerId(int manufacturerId) { this.manufacturerId = manufacturerId; } + public String getName() { return this.name; } - + public void setName(String name) { this.name = name; } + public String getAddressline1() { return this.addressline1; } - + public void setAddressline1(String addressline1) { this.addressline1 = addressline1; } + public String getAddressline2() { return this.addressline2; } - + public void setAddressline2(String addressline2) { this.addressline2 = addressline2; } + public String getCity() { return this.city; } - + public void setCity(String city) { this.city = city; } + public String getState() { return this.state; } - + public void setState(String state) { this.state = state; } + public String getZip() { return this.zip; } - + public void setZip(String zip) { this.zip = zip; } + public String getPhone() { return this.phone; } - + public void setPhone(String phone) { this.phone = phone; } + public String getFax() { return this.fax; } - + public void setFax(String fax) { this.fax = fax; } + public String getEmail() { return this.email; } - + public void setEmail(String email) { this.email = email; } + public String getRep() { return this.rep; } - + public void setRep(String rep) { this.rep = rep; } - - - } - - diff --git a/src/java/DAO/MicroMarket.java b/src/java/DAO/MicroMarket.java index 9538bbd..7a725c4 100644 --- a/src/java/DAO/MicroMarket.java +++ b/src/java/DAO/MicroMarket.java @@ -1,65 +1,60 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - - /** * MicroMarket generated by hbm2java */ -public class MicroMarket implements java.io.Serializable { +public class MicroMarket implements java.io.Serializable { - - private String zipCode; - private Double radius; - private Double areaLength; - private Double areaWidth; + private String zipCode; + private Double radius; + private Double areaLength; + private Double areaWidth; public MicroMarket() { } - public MicroMarket(String zipCode) { this.zipCode = zipCode; } + public MicroMarket(String zipCode, Double radius, Double areaLength, Double areaWidth) { - this.zipCode = zipCode; - this.radius = radius; - this.areaLength = areaLength; - this.areaWidth = areaWidth; + this.zipCode = zipCode; + this.radius = radius; + this.areaLength = areaLength; + this.areaWidth = areaWidth; } - + public String getZipCode() { return this.zipCode; } - + public void setZipCode(String zipCode) { this.zipCode = zipCode; } + public Double getRadius() { return this.radius; } - + public void setRadius(Double radius) { this.radius = radius; } + public Double getAreaLength() { return this.areaLength; } - + public void setAreaLength(Double areaLength) { this.areaLength = areaLength; } + public Double getAreaWidth() { return this.areaWidth; } - + public void setAreaWidth(Double areaWidth) { this.areaWidth = areaWidth; } - - - } - - diff --git a/src/java/DAO/Product.java b/src/java/DAO/Product.java index 5b86a98..03c14a1 100644 --- a/src/java/DAO/Product.java +++ b/src/java/DAO/Product.java @@ -1,104 +1,104 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - import java.math.BigDecimal; /** * Product generated by hbm2java */ -public class Product implements java.io.Serializable { +public class Product implements java.io.Serializable { - - private int productId; - private int manufacturerId; - private String productCode; - private BigDecimal purchaseCost; - private Integer quantityOnHand; - private BigDecimal markup; - private String available; - private String description; + private int productId; + private int manufacturerId; + private String productCode; + private BigDecimal purchaseCost; + private Integer quantityOnHand; + private BigDecimal markup; + private String available; + private String description; public Product() { } - public Product(int productId, int manufacturerId, String productCode) { this.productId = productId; this.manufacturerId = manufacturerId; this.productCode = productCode; } + public Product(int productId, int manufacturerId, String productCode, BigDecimal purchaseCost, Integer quantityOnHand, BigDecimal markup, String available, String description) { - this.productId = productId; - this.manufacturerId = manufacturerId; - this.productCode = productCode; - this.purchaseCost = purchaseCost; - this.quantityOnHand = quantityOnHand; - this.markup = markup; - this.available = available; - this.description = description; + this.productId = productId; + this.manufacturerId = manufacturerId; + this.productCode = productCode; + this.purchaseCost = purchaseCost; + this.quantityOnHand = quantityOnHand; + this.markup = markup; + this.available = available; + this.description = description; } - + public int getProductId() { return this.productId; } - + public void setProductId(int productId) { this.productId = productId; } + public int getManufacturerId() { return this.manufacturerId; } - + public void setManufacturerId(int manufacturerId) { this.manufacturerId = manufacturerId; } + public String getProductCode() { return this.productCode; } - + public void setProductCode(String productCode) { this.productCode = productCode; } + public BigDecimal getPurchaseCost() { return this.purchaseCost; } - + public void setPurchaseCost(BigDecimal purchaseCost) { this.purchaseCost = purchaseCost; } + public Integer getQuantityOnHand() { return this.quantityOnHand; } - + public void setQuantityOnHand(Integer quantityOnHand) { this.quantityOnHand = quantityOnHand; } + public BigDecimal getMarkup() { return this.markup; } - + public void setMarkup(BigDecimal markup) { this.markup = markup; } + public String getAvailable() { return this.available; } - + public void setAvailable(String available) { this.available = available; } + public String getDescription() { return this.description; } - + public void setDescription(String description) { this.description = description; } - - - } - - diff --git a/src/java/DAO/ProductCode.java b/src/java/DAO/ProductCode.java index 905cb38..4de2f19 100644 --- a/src/java/DAO/ProductCode.java +++ b/src/java/DAO/ProductCode.java @@ -1,57 +1,51 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - - /** * ProductCode generated by hbm2java */ -public class ProductCode implements java.io.Serializable { +public class ProductCode implements java.io.Serializable { - - private String prodCode; - private char discountCode; - private String description; + private String prodCode; + private char discountCode; + private String description; public ProductCode() { } - public ProductCode(String prodCode, char discountCode) { this.prodCode = prodCode; this.discountCode = discountCode; } + public ProductCode(String prodCode, char discountCode, String description) { - this.prodCode = prodCode; - this.discountCode = discountCode; - this.description = description; + this.prodCode = prodCode; + this.discountCode = discountCode; + this.description = description; } - + public String getProdCode() { return this.prodCode; } - + public void setProdCode(String prodCode) { this.prodCode = prodCode; } + public char getDiscountCode() { return this.discountCode; } - + public void setDiscountCode(char discountCode) { this.discountCode = discountCode; } + public String getDescription() { return this.description; } - + public void setDescription(String description) { this.description = description; } - - - } - - diff --git a/src/java/DAO/PurchaseOrder.java b/src/java/DAO/PurchaseOrder.java index 849a4f3..79eb769 100644 --- a/src/java/DAO/PurchaseOrder.java +++ b/src/java/DAO/PurchaseOrder.java @@ -1,105 +1,105 @@ package DAO; // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 - import java.math.BigDecimal; import java.util.Date; /** * PurchaseOrder generated by hbm2java */ -public class PurchaseOrder implements java.io.Serializable { +public class PurchaseOrder implements java.io.Serializable { - - private int orderNum; - private int customerId; - private int productId; - private Short quantity; - private BigDecimal shippingCost; - private Date salesDate; - private Date shippingDate; - private String freightCompany; + private int orderNum; + private int customerId; + private int productId; + private Short quantity; + private BigDecimal shippingCost; + private Date salesDate; + private Date shippingDate; + private String freightCompany; public PurchaseOrder() { } - public PurchaseOrder(int orderNum, int customerId, int productId) { this.orderNum = orderNum; this.customerId = customerId; this.productId = productId; } + public PurchaseOrder(int orderNum, int customerId, int productId, Short quantity, BigDecimal shippingCost, Date salesDate, Date shippingDate, String freightCompany) { - this.orderNum = orderNum; - this.customerId = customerId; - this.productId = productId; - this.quantity = quantity; - this.shippingCost = shippingCost; - this.salesDate = salesDate; - this.shippingDate = shippingDate; - this.freightCompany = freightCompany; + this.orderNum = orderNum; + this.customerId = customerId; + this.productId = productId; + this.quantity = quantity; + this.shippingCost = shippingCost; + this.salesDate = salesDate; + this.shippingDate = shippingDate; + this.freightCompany = freightCompany; } - + public int getOrderNum() { return this.orderNum; } - + public void setOrderNum(int orderNum) { this.orderNum = orderNum; } + public int getCustomerId() { return this.customerId; } - + public void setCustomerId(int customerId) { this.customerId = customerId; } + public int getProductId() { return this.productId; } - + public void setProductId(int productId) { this.productId = productId; } + public Short getQuantity() { return this.quantity; } - + public void setQuantity(Short quantity) { this.quantity = quantity; } + public BigDecimal getShippingCost() { return this.shippingCost; } - + public void setShippingCost(BigDecimal shippingCost) { this.shippingCost = shippingCost; } + public Date getSalesDate() { return this.salesDate; } - + public void setSalesDate(Date salesDate) { this.salesDate = salesDate; } + public Date getShippingDate() { return this.shippingDate; } - + public void setShippingDate(Date shippingDate) { this.shippingDate = shippingDate; } + public String getFreightCompany() { return this.freightCompany; } - + public void setFreightCompany(String freightCompany) { this.freightCompany = freightCompany; } - - - } - - diff --git a/src/java/Exceptions/InvalidParameter.java b/src/java/Exceptions/InvalidParameter.java index 41c0691..8b0e24e 100644 --- a/src/java/Exceptions/InvalidParameter.java +++ b/src/java/Exceptions/InvalidParameter.java @@ -10,6 +10,7 @@ package Exceptions; * @author flifloo */ public class InvalidParameter extends Exception { + public InvalidParameter(String message) { super(message); } diff --git a/src/java/controller/BddController.java b/src/java/controller/BddController.java index 6d49517..246b8df 100644 --- a/src/java/controller/BddController.java +++ b/src/java/controller/BddController.java @@ -4,6 +4,7 @@ * and open the template in the editor. */ package controller; + import DAO.*; import Exceptions.InvalidParameter; import java.math.BigDecimal; @@ -20,424 +21,439 @@ import javax.servlet.http.*; import javax.servlet.*; import org.hibernate.exception.ConstraintViolationException; - - - /** * * @author faycal */ -public class BddController extends MultiActionController { +public class BddController extends MultiActionController { + private String login; private String pwd; private User utilisateur; private HttpSession session; - public BddController() {} - + + public BddController() { + } + private void sessionInit(HttpServletRequest request) { - if (login == null) - login=request.getUserPrincipal().getName(); - if (utilisateur == null) - utilisateur =new User(login); - + if (login == null) { + login = request.getUserPrincipal().getName(); + } + if (utilisateur == null) { + utilisateur = new User(login); + } + if (session == null) { - session=request.getSession(); + session = request.getSession(); session.setAttribute("user", utilisateur); } } - - public ModelAndView menu(HttpServletRequest request, - HttpServletResponse response){ + + public ModelAndView menu(HttpServletRequest request, + HttpServletResponse response) { sessionInit(request); - System.out.println ("nbuser="+User.getCompteur()); - return new ModelAndView("menu").addObject("user",utilisateur); - + System.out.println("nbuser=" + User.getCompteur()); + return new ModelAndView("menu").addObject("user", utilisateur); + } - public ModelAndView logout(HttpServletRequest request, - HttpServletResponse response){ - sessionInit(request); + + public ModelAndView logout(HttpServletRequest request, + HttpServletResponse response) { request.getSession().invalidate(); - - - return new ModelAndView("deconnexion"); - + + return new ModelAndView("logout"); + } - - public ModelAndView list(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("resultat"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - - switch (type) { - case "customer": + + public ModelAndView list(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("resultat"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + + switch (type) { + case "customer": mv.addObject("results", new MagasinHelper().getClientsColums()); mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate")); - break; - case "product": - mv.addObject("results", new MagasinHelper().getProductsColums()); - mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description")); - mv.addObject("relation", new HashMap() {{ - put("productCode", "prodCode"); - }}); - break; - case "purchase": + break; + case "product": + mv.addObject("results", new MagasinHelper().getProductsColums()); + mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description")); + mv.addObject("relation", new HashMap() { + { + put("productCode", "prodCode"); + } + }); + break; + case "purchase": mv.addObject("results", new MagasinHelper().getPurchaseColums()); mv.addObject("colonnes", Arrays.asList("orderNum", "customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany")); - mv.addObject("relation", new HashMap() {{ - put("customerId", "customer"); - put("productId", "product"); - }}); + mv.addObject("relation", new HashMap() { + { + put("customerId", "customer"); + put("productId", "product"); + } + }); break; - case "discount": - mv.addObject("results", new MagasinHelper().getDiscountCodesColums()); - mv.addObject("colonnes", Arrays.asList("discountCode", "rate")); - break; - case "prodCode": - mv.addObject("results", new MagasinHelper().getProductCodesColums()); - mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description")); - mv.addObject("relation", new HashMap() {{ - put("discountCode", "discount"); - }}); - break; - default: - mv.addObject("error", "Type not found"); - } - - return mv; - } - - public ModelAndView formAdd(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("detail"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - mv.addObject("save", true); - - switch (type) { - case "customer": - mv.addObject("code",new MagasinHelper().getDiscountCodes()); - mv.addObject("cpostaux",new MagasinHelper().getZipCode()); - break; - case "product": - mv.addObject("manufacturers", new MagasinHelper().getManufacturers()); - mv.addObject("productCodes", new MagasinHelper().getProductCodes()); - break; - case "purchase": + case "discount": + mv.addObject("results", new MagasinHelper().getDiscountCodesColums()); + mv.addObject("colonnes", Arrays.asList("discountCode", "rate")); + break; + case "prodCode": + mv.addObject("results", new MagasinHelper().getProductCodesColums()); + mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description")); + mv.addObject("relation", new HashMap() { + { + put("discountCode", "discount"); + } + }); + break; + default: + mv.addObject("error", "Type not found"); + } + + return mv; + } + + public ModelAndView formAdd(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("detail"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + mv.addObject("save", true); + + switch (type) { + case "customer": + mv.addObject("code", new MagasinHelper().getDiscountCodes()); + mv.addObject("cpostaux", new MagasinHelper().getZipCode()); + break; + case "product": + mv.addObject("manufacturers", new MagasinHelper().getManufacturers()); + mv.addObject("productCodes", new MagasinHelper().getProductCodes()); + break; + case "purchase": mv.addObject("customers", new MagasinHelper().getClients()); mv.addObject("products", new MagasinHelper().getProducts()); break; - case "discount": - break; - case "prodCode": - mv.addObject("code",new MagasinHelper().getDiscountCodes()); - break; - default: - mv.addObject("error", "Type not found"); - } + case "discount": + break; + case "prodCode": + mv.addObject("code", new MagasinHelper().getDiscountCodes()); + break; + default: + mv.addObject("error", "Type not found"); + } - return mv; - } - - public ModelAndView detail(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("detail"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - - switch (type) { - case "customer": + return mv; + } + + public ModelAndView detail(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("detail"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + + switch (type) { + case "customer": mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num")))); - mv.addObject("code",new MagasinHelper().getDiscountCodes()); - mv.addObject("cpostaux",new MagasinHelper().getZipCode()); - break; - case "product": - mv.addObject("result", new MagasinHelper().getProduct(Integer.parseInt(request.getParameter("num")))); - mv.addObject("manufacturers", new MagasinHelper().getManufacturers()); - mv.addObject("productCodes", new MagasinHelper().getProductCodes()); - break; - case "purchase": + mv.addObject("code", new MagasinHelper().getDiscountCodes()); + mv.addObject("cpostaux", new MagasinHelper().getZipCode()); + break; + case "product": + mv.addObject("result", new MagasinHelper().getProduct(Integer.parseInt(request.getParameter("num")))); + mv.addObject("manufacturers", new MagasinHelper().getManufacturers()); + mv.addObject("productCodes", new MagasinHelper().getProductCodes()); + break; + case "purchase": mv.addObject("result", new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("num")))); mv.addObject("customers", new MagasinHelper().getClients()); mv.addObject("products", new MagasinHelper().getProducts()); break; - case "discount": - mv.addObject("result", new MagasinHelper().getDiscountCode(request.getParameter("num").charAt(0))); - break; - case "prodCode": - mv.addObject("result", new MagasinHelper().getProductCode(request.getParameter("num"))); - mv.addObject("code",new MagasinHelper().getDiscountCodes()); - break; - default: - mv.addObject("error", "Type not found"); - } - - return mv; - } - public ModelAndView find(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("resultat"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - - String query = request.getParameter("query"); - if (query == null || query.isEmpty()) - mv.addObject("error", "No query"); - else { - List customers = new ArrayList(); - try { - customers.addAll(new MagasinHelper().getClientsColums(Integer.parseInt(query))); - } catch (NumberFormatException exception) { - - } - - query = "%".concat(query.concat("%")); - customers.addAll(new MagasinHelper().getClientsColums(query)); - - if (customers.size() == 0) - mv.addObject("error", "No user found :/"); - else - mv.addObject("results", customers); - } - MagasinHelper helper = new MagasinHelper(); - return mv; - } - - public ModelAndView achats(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - ModelAndView mv = new ModelAndView("achats"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("achats",new MagasinHelper().getPurchases(Integer.parseInt(request.getParameter("customerId")))); - return mv; - } - - public ModelAndView delete(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("confirm"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - - switch (type) { - case "customer": - new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("customerId"))); - break; - case "product": - new MagasinHelper().deleteProduct(Integer.parseInt(request.getParameter("productId"))); - break; - case "purchase": - new MagasinHelper().deletePurchase(Integer.parseInt(request.getParameter("orderNum"))); - break; - case "discount": - new MagasinHelper().deleteDiscountCode(request.getParameter("discountCode").charAt(0)); - break; - case "prodCode": - new MagasinHelper().deleteProductCode(request.getParameter("prodCode")); - break; - default: - mv.addObject("error", "Type not found"); - return mv; - } - - mv.addObject("confirm","suppression effectuée"); - return mv; - - } - - private char paramChar(HttpServletRequest request, String name) throws InvalidParameter { - String param = paramNotNull(request, name); - if (param.length() > 1) - throw new InvalidParameter("Invalid ".concat(name)); - return param.charAt(0); - } - - private int parseParamInt(HttpServletRequest request, String name) throws InvalidParameter { - try { - return Integer.parseInt(request.getParameter(name)); - } catch (Exception e) { - throw new InvalidParameter("Invalid numer for ".concat(name)); - } - } - - private int parseParamInt(String param, String name) throws InvalidParameter { - try { - return Integer.parseInt(param); - } catch (Exception e) { - throw new InvalidParameter("Invalid numer for ".concat(name)); - } - } - - private BigDecimal parseParamBigDecimal(HttpServletRequest request, String name, int precision) throws InvalidParameter { - BigDecimal bc; - try { - bc = BigDecimal.valueOf(Long.parseLong(request.getParameter("rate"))); - } catch (Exception e) { - throw new InvalidParameter("Invalid big int for ".concat(name)); - } - - if (bc.precision() > precision) - throw new InvalidParameter("Precision for ".concat(name).concat(" shounld be over ".concat(String.valueOf(precision)))); - return bc; - } - - private Short parseParamShort(HttpServletRequest request, String name) throws InvalidParameter { - try { - return Short.valueOf(request.getParameter("rate")); - } catch (Exception e) { - throw new InvalidParameter("Invalid short number for ".concat(name)); - } - } - - private String paramNotNull(HttpServletRequest request, String name) throws InvalidParameter { - String param = request.getParameter(name); - if (param == null || param.isEmpty()) - throw new InvalidParameter(name.concat(" should not be empty")); - return param; - } - - private String paramLength(HttpServletRequest request, String name, int length) throws InvalidParameter { - String param = request.getParameter(name); - if (param.length() > length) - throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters"))); - return param; - } - - private String paramLength(String param, String name, int length) throws InvalidParameter { - if (param.length() > length) - throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters"))); - return param; - } - - private String paramAvailable(HttpServletRequest request, String name) throws InvalidParameter { - String param = request.getParameter(name).toUpperCase(); - if (!param.equals("TRUE") && !param.equals("FALSE")) - throw new InvalidParameter("It's true or false for ".concat(name)); - return param; - } - - private Date paramDate(HttpServletRequest request, String name) throws InvalidParameter { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - try { - return format.parse(request.getParameter(name)); - } catch(Exception e) { - throw new InvalidParameter("Invalid date for ".concat(name)); - } - } - - private Object fetchDetailsData(HttpServletRequest request, ModelAndView mv) throws Exception { - String type = request.getParameter("type"); - Object data = null; - - try { - switch (type) { - case "customer": - int customerId = parseParamInt(request, "customerId"); - char discountCode = paramChar(request, "discountCode"); - String zip = paramLength(paramNotNull(request, "zip"), "zip", 10); - String name = paramLength(request, "name", 30); - String addressline1 = paramLength(request, "addressline1", 30); - String addressline2 = paramLength(request, "addressline2", 30); - String city = paramLength(request, "city", 25); - String state = paramLength(request, "state", 2); - String phone = paramLength(request, "phone", 12); - String fax = paramLength(request, "fax", 12); - String email = paramLength(request, "email", 40); - int creditLimit = parseParamInt(request, "creditLimit"); - data = new Customer(customerId, discountCode, zip, name, addressline1, addressline2, city, state, phone, fax, email, creditLimit); - break; - case "product": - int productId = parseParamInt(request, "productId"); - int manufacturerId = parseParamInt(paramNotNull(request, "manufacturerId"), "manufacturerId"); - String productCode = paramLength(paramNotNull(request, "productCode"), "productCode", 2); - BigDecimal purchaseCost = parseParamBigDecimal(request, "purchaseCost", 12); - int quantityOnHand = parseParamInt(request, "quantityOnHand"); - BigDecimal markup = parseParamBigDecimal(request, "markup", 12); - String available = paramAvailable(request, "available"); - String description = paramLength(request, "description", 50); - data = new Product(productId, manufacturerId, productCode, purchaseCost, quantityOnHand, markup, available, description); - break; - case "purchase": - int orderNum = parseParamInt(request, "orderNum"); - customerId = parseParamInt(paramNotNull(request, "customerId"), "customerId"); - productId = parseParamInt(paramNotNull(request, "productId"), "productId"); - Short quantity = parseParamShort(request, "quantity"); - BigDecimal shippingCost = parseParamBigDecimal(request, "shippingCost", 12); - Date salesDate = paramDate(request, "salesDate"); - Date shippingDate = paramDate(request, "shippingDate"); - String freightCompany = paramLength(request, "freightCompany", 30); - data = new PurchaseOrder(orderNum, customerId, productId, quantity, shippingCost, salesDate, shippingDate, freightCompany); - break; case "discount": - discountCode = paramChar(request, "discountCode"); - BigDecimal rate = parseParamBigDecimal(request, "rate", 4); - data = new DiscountCode(discountCode, rate); + mv.addObject("result", new MagasinHelper().getDiscountCode(request.getParameter("num").charAt(0))); break; case "prodCode": - productCode = paramLength(request, "prodCode", 2); - discountCode = paramChar(request, "discountCode"); - description = paramLength(request, "description", 10); - data = new ProductCode(productCode, discountCode, description); + mv.addObject("result", new MagasinHelper().getProductCode(request.getParameter("num"))); + mv.addObject("code", new MagasinHelper().getDiscountCodes()); + break; + default: + mv.addObject("error", "Type not found"); + } + + return mv; + } + + public ModelAndView find(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("resultat"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + + String query = request.getParameter("query"); + if (query == null || query.isEmpty()) { + mv.addObject("error", "No query"); + } else { + List customers = new ArrayList(); + try { + customers.addAll(new MagasinHelper().getClientsColums(Integer.parseInt(query))); + } catch (NumberFormatException exception) { + + } + + query = "%".concat(query.concat("%")); + customers.addAll(new MagasinHelper().getClientsColums(query)); + + if (customers.size() == 0) { + mv.addObject("error", "No user found :/"); + } else { + mv.addObject("results", customers); + } + } + MagasinHelper helper = new MagasinHelper(); + return mv; + } + + public ModelAndView achats(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + ModelAndView mv = new ModelAndView("achats"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("achats", new MagasinHelper().getPurchases(Integer.parseInt(request.getParameter("customerId")))); + return mv; + } + + public ModelAndView delete(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("confirm"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + + switch (type) { + case "customer": + new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("customerId"))); + break; + case "product": + new MagasinHelper().deleteProduct(Integer.parseInt(request.getParameter("productId"))); + break; + case "purchase": + new MagasinHelper().deletePurchase(Integer.parseInt(request.getParameter("orderNum"))); + break; + case "discount": + new MagasinHelper().deleteDiscountCode(request.getParameter("discountCode").charAt(0)); + break; + case "prodCode": + new MagasinHelper().deleteProductCode(request.getParameter("prodCode")); break; default: mv.addObject("error", "Type not found"); return mv; } - } catch (InvalidParameter e) { - mv.addObject("error", e.getMessage()); - } - - return data; - } - - public ModelAndView save(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("confirm"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - Object data = fetchDetailsData(request, mv); - - if (data != null) { - try { - new MagasinHelper().add(data); - mv.addObject("confirm","Save completed"); - } catch (ConstraintViolationException e) { - mv.addObject("error", e.getSQLException().getMessage()); - } catch (Exception e) { - mv.addObject("error", e.getMessage()); + + mv.addObject("confirm", "suppression effectuée"); + return mv; + + } + + private char paramChar(HttpServletRequest request, String name) throws InvalidParameter { + String param = paramNotNull(request, name); + if (param.length() > 1) { + throw new InvalidParameter("Invalid ".concat(name)); } - } - return mv; - } - - public ModelAndView update(HttpServletRequest request, - HttpServletResponse response) throws Exception { - sessionInit(request); - String type = request.getParameter("type"); - ModelAndView mv = new ModelAndView("confirm"); - mv.addObject("user",session.getAttribute("user")); - mv.addObject("type", type); - Object data = fetchDetailsData(request, mv); - - if (data != null) { + return param.charAt(0); + } + + private int parseParamInt(HttpServletRequest request, String name) throws InvalidParameter { try { - new MagasinHelper().update(data); - mv.addObject("confirm","Update completed"); + return Integer.parseInt(request.getParameter(name)); } catch (Exception e) { - mv.addObject("error", e.getMessage()); + throw new InvalidParameter("Invalid numer for ".concat(name)); } } - return mv; - } + + private int parseParamInt(String param, String name) throws InvalidParameter { + try { + return Integer.parseInt(param); + } catch (Exception e) { + throw new InvalidParameter("Invalid numer for ".concat(name)); + } + } + + private BigDecimal parseParamBigDecimal(HttpServletRequest request, String name, int precision) throws InvalidParameter { + BigDecimal bc; + try { + bc = BigDecimal.valueOf(Long.parseLong(request.getParameter("rate"))); + } catch (Exception e) { + throw new InvalidParameter("Invalid big int for ".concat(name)); + } + + if (bc.precision() > precision) { + throw new InvalidParameter("Precision for ".concat(name).concat(" shounld be over ".concat(String.valueOf(precision)))); + } + return bc; + } + + private Short parseParamShort(HttpServletRequest request, String name) throws InvalidParameter { + try { + return Short.valueOf(request.getParameter("rate")); + } catch (Exception e) { + throw new InvalidParameter("Invalid short number for ".concat(name)); + } + } + + private String paramNotNull(HttpServletRequest request, String name) throws InvalidParameter { + String param = request.getParameter(name); + if (param == null || param.isEmpty()) { + throw new InvalidParameter(name.concat(" should not be empty")); + } + return param; + } + + private String paramLength(HttpServletRequest request, String name, int length) throws InvalidParameter { + String param = request.getParameter(name); + if (param.length() > length) { + throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters"))); + } + return param; + } + + private String paramLength(String param, String name, int length) throws InvalidParameter { + if (param.length() > length) { + throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters"))); + } + return param; + } + + private String paramAvailable(HttpServletRequest request, String name) throws InvalidParameter { + String param = request.getParameter(name).toUpperCase(); + if (!param.equals("TRUE") && !param.equals("FALSE")) { + throw new InvalidParameter("It's true or false for ".concat(name)); + } + return param; + } + + private Date paramDate(HttpServletRequest request, String name) throws InvalidParameter { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + return format.parse(request.getParameter(name)); + } catch (Exception e) { + throw new InvalidParameter("Invalid date for ".concat(name)); + } + } + + private Object fetchDetailsData(HttpServletRequest request, ModelAndView mv) throws Exception { + String type = request.getParameter("type"); + Object data = null; + + try { + switch (type) { + case "customer": + int customerId = parseParamInt(request, "customerId"); + char discountCode = paramChar(request, "discountCode"); + String zip = paramLength(paramNotNull(request, "zip"), "zip", 10); + String name = paramLength(request, "name", 30); + String addressline1 = paramLength(request, "addressline1", 30); + String addressline2 = paramLength(request, "addressline2", 30); + String city = paramLength(request, "city", 25); + String state = paramLength(request, "state", 2); + String phone = paramLength(request, "phone", 12); + String fax = paramLength(request, "fax", 12); + String email = paramLength(request, "email", 40); + int creditLimit = parseParamInt(request, "creditLimit"); + data = new Customer(customerId, discountCode, zip, name, addressline1, addressline2, city, state, phone, fax, email, creditLimit); + break; + case "product": + int productId = parseParamInt(request, "productId"); + int manufacturerId = parseParamInt(paramNotNull(request, "manufacturerId"), "manufacturerId"); + String productCode = paramLength(paramNotNull(request, "productCode"), "productCode", 2); + BigDecimal purchaseCost = parseParamBigDecimal(request, "purchaseCost", 12); + int quantityOnHand = parseParamInt(request, "quantityOnHand"); + BigDecimal markup = parseParamBigDecimal(request, "markup", 12); + String available = paramAvailable(request, "available"); + String description = paramLength(request, "description", 50); + data = new Product(productId, manufacturerId, productCode, purchaseCost, quantityOnHand, markup, available, description); + break; + case "purchase": + int orderNum = parseParamInt(request, "orderNum"); + customerId = parseParamInt(paramNotNull(request, "customerId"), "customerId"); + productId = parseParamInt(paramNotNull(request, "productId"), "productId"); + Short quantity = parseParamShort(request, "quantity"); + BigDecimal shippingCost = parseParamBigDecimal(request, "shippingCost", 12); + Date salesDate = paramDate(request, "salesDate"); + Date shippingDate = paramDate(request, "shippingDate"); + String freightCompany = paramLength(request, "freightCompany", 30); + data = new PurchaseOrder(orderNum, customerId, productId, quantity, shippingCost, salesDate, shippingDate, freightCompany); + break; + case "discount": + discountCode = paramChar(request, "discountCode"); + BigDecimal rate = parseParamBigDecimal(request, "rate", 4); + data = new DiscountCode(discountCode, rate); + break; + case "prodCode": + productCode = paramLength(request, "prodCode", 2); + discountCode = paramChar(request, "discountCode"); + description = paramLength(request, "description", 10); + data = new ProductCode(productCode, discountCode, description); + break; + default: + mv.addObject("error", "Type not found"); + return mv; + } + } catch (InvalidParameter e) { + mv.addObject("error", e.getMessage()); + } + + return data; + } + + public ModelAndView save(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("confirm"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + Object data = fetchDetailsData(request, mv); + + if (data != null) { + try { + new MagasinHelper().add(data); + mv.addObject("confirm", "Save completed"); + } catch (ConstraintViolationException e) { + mv.addObject("error", e.getSQLException().getMessage()); + } catch (Exception e) { + mv.addObject("error", e.getMessage()); + } + } + return mv; + } + + public ModelAndView update(HttpServletRequest request, + HttpServletResponse response) throws Exception { + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("confirm"); + mv.addObject("user", session.getAttribute("user")); + mv.addObject("type", type); + Object data = fetchDetailsData(request, mv); + + if (data != null) { + try { + new MagasinHelper().update(data); + mv.addObject("confirm", "Update completed"); + } catch (Exception e) { + mv.addObject("error", e.getMessage()); + } + } + return mv; + } } diff --git a/src/java/service/User.java b/src/java/service/User.java index 55f3825..f8bd8ed 100644 --- a/src/java/service/User.java +++ b/src/java/service/User.java @@ -4,16 +4,19 @@ * and open the template in the editor. */ package service; + import java.io.Serializable; + /** * * @author faycal */ public class User implements Serializable { + private String login; private String pwd; private int userId; - static private int compteur=0; + static private int compteur = 0; public static int getCompteur() { return compteur; @@ -21,22 +24,24 @@ public class User implements Serializable { public User() { super(); - userId=compteur++; + userId = compteur++; } - public void finalize(){ - + + public void finalize() { + compteur--; } - public User(String login) { + + public User(String login) { this.login = login; - userId=compteur++; - + userId = compteur++; + } public User(String login, String pwd) { this.login = login; this.pwd = pwd; - userId=compteur++; + userId = compteur++; } public String getLogin() { @@ -54,5 +59,5 @@ public class User implements Serializable { public void setPwd(String pwd) { this.pwd = pwd; } - + } diff --git a/web/WEB-INF/jsp/achats.jsp b/web/WEB-INF/jsp/achats.jsp index f285c3c..c71013a 100644 --- a/web/WEB-INF/jsp/achats.jsp +++ b/web/WEB-INF/jsp/achats.jsp @@ -8,27 +8,27 @@ <%@include file="header.jsp" %> - - + +

Achats du client n°<%=request.getParameter("customerId")%>

- - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
${cli.orderNum}${cli.customerId}${cli.productId}${cli.quantity}${cli.shippingCost}${cli.salesDate}${cli.shippingDate}${cli.freightCompany}
${cli.orderNum}${cli.customerId}${cli.productId}${cli.quantity}${cli.shippingCost}${cli.salesDate}${cli.shippingDate}${cli.freightCompany}
- - + + diff --git a/web/WEB-INF/jsp/confirm.jsp b/web/WEB-INF/jsp/confirm.jsp index 5233c5f..7440c6f 100644 --- a/web/WEB-INF/jsp/confirm.jsp +++ b/web/WEB-INF/jsp/confirm.jsp @@ -13,7 +13,7 @@ <%@include file="header.jsp" %> - +

${error != null ? error : confirm}

diff --git a/web/WEB-INF/jsp/deconnexion.jsp b/web/WEB-INF/jsp/deconnexion.jsp deleted file mode 100644 index 582931e..0000000 --- a/web/WEB-INF/jsp/deconnexion.jsp +++ /dev/null @@ -1,18 +0,0 @@ -<%-- - Document : deconnexion - Created on : 1 juin 2020, 17:09:38 - Author : faycal ---%> - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - Deconnexion - - -

Vous etes deconnecte

- <%response.sendRedirect("/Bdd_Spring_HI/");%> - - diff --git a/web/WEB-INF/jsp/detail.jsp b/web/WEB-INF/jsp/detail.jsp index 73ea3a9..ded1bf0 100644 --- a/web/WEB-INF/jsp/detail.jsp +++ b/web/WEB-INF/jsp/detail.jsp @@ -8,7 +8,7 @@ <%@include file="header.jsp" %> - + @@ -106,12 +106,12 @@ checked id="isavailable" /> - - checked id="notavailable" /> -

-

- - + + checked id="notavailable" /> +

+

+ +

@@ -185,7 +185,7 @@

- + diff --git a/web/WEB-INF/jsp/error.jsp b/web/WEB-INF/jsp/error.jsp deleted file mode 100644 index 14af0fd..0000000 --- a/web/WEB-INF/jsp/error.jsp +++ /dev/null @@ -1,18 +0,0 @@ -<%-- - Document : error - Created on : 4 mars 2018, 20:54:56 - Author : faycal ---%> - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - Erreur - - - <%@include file="header.jsp" %> -

${erreur}

- - diff --git a/web/WEB-INF/jsp/form_inscription.jsp b/web/WEB-INF/jsp/form_inscription.jsp index 4dbc842..3f86767 100644 --- a/web/WEB-INF/jsp/form_inscription.jsp +++ b/web/WEB-INF/jsp/form_inscription.jsp @@ -14,40 +14,40 @@ Bienvenue ${user.login} - +

- - + +

- - + +

- - + +

- +

- - - + + +

diff --git a/web/WEB-INF/jsp/header.jsp b/web/WEB-INF/jsp/header.jsp index 8b7579e..b8ff3d7 100644 --- a/web/WEB-INF/jsp/header.jsp +++ b/web/WEB-INF/jsp/header.jsp @@ -15,7 +15,7 @@
- + diff --git a/web/WEB-INF/jsp/index.jsp b/web/WEB-INF/jsp/index.jsp index 5ebe295..d74394b 100644 --- a/web/WEB-INF/jsp/index.jsp +++ b/web/WEB-INF/jsp/index.jsp @@ -2,5 +2,5 @@ -<% response.sendRedirect("menu.htm"); %> - +<% response.sendRedirect("menu.htm");%> + diff --git a/web/WEB-INF/jsp/login.jsp b/web/WEB-INF/jsp/login.jsp index bc11518..db636fd 100644 --- a/web/WEB-INF/jsp/login.jsp +++ b/web/WEB-INF/jsp/login.jsp @@ -13,20 +13,20 @@ - - - - - - - - - - - - - -
Utilisateur :
Mot de passe :
-
+ + + + + + + + + + + + + +
Utilisateur :
Mot de passe :
+ diff --git a/build/web/WEB-INF/jsp/deconnexion.jsp b/web/WEB-INF/jsp/logout.jsp similarity index 79% rename from build/web/WEB-INF/jsp/deconnexion.jsp rename to web/WEB-INF/jsp/logout.jsp index 582931e..369d703 100644 --- a/build/web/WEB-INF/jsp/deconnexion.jsp +++ b/web/WEB-INF/jsp/logout.jsp @@ -12,7 +12,7 @@ Deconnexion -

Vous etes deconnecte

- <%response.sendRedirect("/Bdd_Spring_HI/");%> +

You are logout

+ <%response.sendRedirect("");%> diff --git a/web/WEB-INF/jsp/menu.jsp b/web/WEB-INF/jsp/menu.jsp index ed702d7..855bcfe 100644 --- a/web/WEB-INF/jsp/menu.jsp +++ b/web/WEB-INF/jsp/menu.jsp @@ -14,7 +14,7 @@ <%@include file="header.jsp" %>

choisissez une opération dans la liste suivante

- +

diff --git a/web/WEB-INF/jsp/recherche.jsp b/web/WEB-INF/jsp/recherche.jsp index bc110dd..90e4c66 100644 --- a/web/WEB-INF/jsp/recherche.jsp +++ b/web/WEB-INF/jsp/recherche.jsp @@ -13,14 +13,14 @@ <%@include file="header.jsp" %> - + -

+

- + diff --git a/web/WEB-INF/jsp/resultat.jsp b/web/WEB-INF/jsp/resultat.jsp index bb96101..b76af35 100644 --- a/web/WEB-INF/jsp/resultat.jsp +++ b/web/WEB-INF/jsp/resultat.jsp @@ -14,7 +14,7 @@ <%@include file="header.jsp" %> - +

${error}

@@ -27,37 +27,37 @@ - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + +
${col}${col}
-
- - - -
-
${v} -
- - - -
-
+
+ + + +
+
${v} +
+ + + +
+