From 076a124e0a643e2f471f873a1b4954a12e3b08ae Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Mon, 24 Feb 2014 14:05:02 +0100 Subject: [PATCH 001/109] Fixes #37 with other default locale than english MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test in error with french default Locale: org.junit.ComparisonFailure: expected:<[ne peut pas être vide]> but was:<[may not be empty]> at org.junit.Assert.assertEquals(Assert.java:115) at org.junit.Assert.assertEquals(Assert.java:144) at org.springframework.samples.petclinic.model.ValidatorTests.emptyFirstName(ValidatorTests.java:39) --- .../samples/petclinic/model/ValidatorTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java index 354c15a9f..9d1e882dd 100644 --- a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java +++ b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java @@ -1,5 +1,6 @@ package org.springframework.samples.petclinic.model; +import java.util.Locale; import java.util.Set; import javax.validation.ConstraintViolation; @@ -10,6 +11,7 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; @@ -32,6 +34,7 @@ public class ValidatorTests { @Test public void emptyFirstName() { + LocaleContextHolder.setLocale(Locale.ENGLISH); Person person = new Person(); person.setFirstName(""); person.setLastName("smith"); From 35a94eaa5dd81fbda1c8ff7c40f40e701bfbf263 Mon Sep 17 00:00:00 2001 From: Mic Date: Mon, 3 Mar 2014 21:24:29 +0800 Subject: [PATCH 002/109] migrating to Spring 4.0.2 --- pom.xml | 2 +- src/main/java/test.html | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/main/java/test.html diff --git a/pom.xml b/pom.xml index 4f37aaa6e..3bee33dd8 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ UTF-8 - 4.0.1.RELEASE + 4.0.2.RELEASE 1.4.3.RELEASE diff --git a/src/main/java/test.html b/src/main/java/test.html new file mode 100644 index 000000000..9a7a99675 --- /dev/null +++ b/src/main/java/test.html @@ -0,0 +1,39 @@ + + + + +

Organisation

+ +

Speakers

+ + + + + + + + + +
+ Sergiu Bodiu +

Sergiu Bodiu

+

Java Consultant at Bank of America

+ Seasoned consultant experienced in large-scale e-commerce projects, passionate about providing innovative technology solutions to solve complex business problems, have extensive knowledge and experience delivering enterprise wide applications. He is skilled in software design, data modeling, stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, test and maintain software product components with strong focus on design elegance and software reuse. +
+ Sergiu Bodiu +

Sergiu Bodiu

+

Java Consultant at Bank of America

+ Seasoned consultant experienced in large-scale e-commerce projects, passionate about providing innovative technology solutions to solve complex business problems, have extensive knowledge and experience delivering enterprise wide applications. He is skilled in software design, data modeling, stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, test and maintain software product components with strong focus on design elegance and software reuse. +
From a4f18cb238e7c7ebc8873f01aece87c8db0ab724 Mon Sep 17 00:00:00 2001 From: Mic Date: Mon, 3 Mar 2014 21:26:12 +0800 Subject: [PATCH 003/109] migrating to Hibernate 4.3.3.Final --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3bee33dd8..820eef16a 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 2.2.7 - 4.3.1.Final + 4.3.3.Final 4.3.1.Final From c8759c4b9e43cc9fa2129c27c02bf42d7187dc11 Mon Sep 17 00:00:00 2001 From: Mic Date: Mon, 3 Mar 2014 21:32:35 +0800 Subject: [PATCH 004/109] upgraded version of SLF4J --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 820eef16a..a543a27fb 100644 --- a/pom.xml +++ b/pom.xml @@ -41,8 +41,8 @@ 1.7.4 - 1.1.0 - 1.7.5 + 1.1.1 + 1.7.6 1.0 From 67ae72f3246e4d7ee2525189555eb0c769a7a3e9 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sun, 23 Mar 2014 17:43:58 +0100 Subject: [PATCH 005/109] Remove public to methods from the ClinicService Any method you define in an interface is by definition public --- .../samples/petclinic/service/ClinicService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java b/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java index c4a65e61e..e72b5c10f 100644 --- a/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java +++ b/src/main/java/org/springframework/samples/petclinic/service/ClinicService.java @@ -32,19 +32,19 @@ import org.springframework.samples.petclinic.model.Visit; */ public interface ClinicService { - public Collection findPetTypes() throws DataAccessException; + Collection findPetTypes() throws DataAccessException; - public Owner findOwnerById(int id) throws DataAccessException; + Owner findOwnerById(int id) throws DataAccessException; - public Pet findPetById(int id) throws DataAccessException; + Pet findPetById(int id) throws DataAccessException; - public void savePet(Pet pet) throws DataAccessException; + void savePet(Pet pet) throws DataAccessException; - public void saveVisit(Visit visit) throws DataAccessException; + void saveVisit(Visit visit) throws DataAccessException; - public Collection findVets() throws DataAccessException; + Collection findVets() throws DataAccessException; - public void saveOwner(Owner owner) throws DataAccessException; + void saveOwner(Owner owner) throws DataAccessException; Collection findOwnerByLastName(String lastName) throws DataAccessException; From 3f0bfbbdbe4ffd8540f09da359c4b0ac7c00222f Mon Sep 17 00:00:00 2001 From: Mic Date: Sat, 12 Apr 2014 23:28:53 +0800 Subject: [PATCH 006/109] updates logo --- src/main/webapp/WEB-INF/jsp/fragments/footer.jsp | 6 +++--- .../resources/images/spring-pivotal-logo.png | Bin 0 -> 2818 bytes 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 src/main/webapp/resources/images/spring-pivotal-logo.png diff --git a/src/main/webapp/WEB-INF/jsp/fragments/footer.jsp b/src/main/webapp/WEB-INF/jsp/fragments/footer.jsp index dccec75d2..c9992c782 100644 --- a/src/main/webapp/WEB-INF/jsp/fragments/footer.jsp +++ b/src/main/webapp/WEB-INF/jsp/fragments/footer.jsp @@ -2,9 +2,9 @@ - - + + diff --git a/src/main/webapp/resources/images/spring-pivotal-logo.png b/src/main/webapp/resources/images/spring-pivotal-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..1840af274b55e7f2d19931a5afecb576cb17f44a GIT binary patch literal 2818 zcmV+d3;pzoP)U?}ki*8K!3QU& z=?Q@la#*cHF7c9)lQnD%-fbIW6LMI;ulLnVO{uE8sz*}v(+_$y>fh?B_r3SMdR3*B zyLa!3Tyn|9EUWmlva*u-2Cu$dF49MdH%OU3BigR>=inF59fo;z=Q2+M=dlw1@dOBi zVw<)qZAFhu`?T%jlK>OtO_0k%0fc}7FVUf`a>i!^96PjiO+dkOX#XH@qT@O*uoupa z$}9qe8VL>5qOCFJGN8e?sNwtCvyNz6TXuz@y67l%j=Ff9>SUO!?(_h1&e4Khn*cZj zTgE+lMvs93X*_uTVu9(~GJ~U_)j7V`bG4nWoJ(mWG{}KxoRLN1=g{*ik6b9VUVh>Y z?AyqjCzqK82!o@?mTMYPy8pf}AG}byEWZAghsA~SU#l#0!!W(wKG^SKwn?e5}gX;8|UH4Ik@p=SIY3>?`lQEl!VaP~SIns5d;X#br|86BKV( zDETX`jK^hP6gia#p_e_FhSdgrdj8w59LF0rdFLMiwwjtJ@c@UKLr9XLreHmBx;r(b zW9ziPp(wabpfqhdziR;99qn8wQdyY0Zjl=b=(;? zrZP75_n%iel?P$VGcj<0Lcv>H`QdNHOG+@FB#+#qS)~l%=n40{4J_XtTXG>ryR<6| zwvNNSpeP-FzAC17=m>jWqo~}^w7+P0?t$Yw*A3-UW6y@;d-fQp1;eq0q*&W$QU3Ex zlhi;P)aeo(!*LspO1rN(8T{x9j*3O`LPfcXCdQ|nql<5n6iWC$S<)*hN@lh48JeNw zSw5X^^)eWvo>*{M)fB`zuzvKRr^J)rczPtb9(V6nhDO^oP^fjai&Tjvqy==%F$|bO z^_Bb7`Chuhx9E7_(KUixltB=Mw!r`ntmL_a?n}n*r!D5O9RM^L?(+efmsKMnJ-` zMjD^r$`WVUVi&#KhPX;Mh%JjTSl8=?;|}@0r9}tGIal`#Px1N>emzxiXz@{2sVnh? z&>A}e&2RumnAAJNy<9cJp{fHo*2e^nzyOZpz}aR(qdv57=}dEek*%vz-7+HA&9_LB0dIk#UHOFH#gnjx{^t{6-?ZI)nF0qOai$ z>qX>I*GmDAq0M_tI_5|N$BmB$SwI3V{*V3A%4!^B_h(d}%@e`OWn=#an;>rFgM)InhJGyWIZl z)>tb80XN20c?OuRG%v!jj1Gk19Po5g+gH=P1NY9=Csd|Q-Y|;dfE4%|?=O2&-WXI8 z01nTydXTBiIY3wLum1Xz_!FKZ%|pHWpFeq(jT>!`6&0?josi@3QC!>)-NfsbRanpf zrmSRWrR4d(A^`yZ2pVkX;=hA0Rhz>1-8&UZ~#@o%-OD z8!;$eXq-satV0P&$hk)cBB43t!h<=9Kr5N?APx8`NpBG5pppQgnN)+a=z8l=Gc zieZY!juB`E3W(&oxLxe0@6wR%FaYH0H!{wP=)4+VTT*D#A$y|=x8W9jkLY`bU>u4OVd4wiHlNz98)8gTnH@w zd*m%Zi`eqVf|0+^f9n;mL?E8|-o5-s+q045F+v<*wnX{}<#@P6%CK}fKra#}Gv|^5 z-ln0~P4eSHN^qRk12$ByRRdY4i=U4X-xw{ z67B7albMrST(>QbMt0hg*z(JkY2xgDa=YYJd zDUfmcu4a7JSqTaZN*93Clxue7U_@Mt0GbsfaxoWq-CVwTMDhh{x0nsay_+JzhygY zD9?F7(ThlJ+mWS5ZBt7@kuc;0fVfGN2{cLT4egJDngsx||qtoUdeBHvE)#s;fhX9aG`Ua46TU}M!{Y08oh!V5s@<6fwLkAx|4 zOac0YEo)*CUIV~TywFy@Q1et}TkD8`@+0>%WUDHBunGyZHEXY3pSxsda(ScGgrKxY zu}292fxsiY{)cB{&jBF7qW~1X0~tZh00ej;NzXKI)SR~fcLC(kqWDGOHVQz_Yw2q))Grv!Kiq|hpac-d_#ye3zV9${Uy4=~!f zb Date: Sat, 12 Apr 2014 23:29:02 +0800 Subject: [PATCH 007/109] updated lib versions --- pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index a543a27fb..0c3d0c55e 100644 --- a/pom.xml +++ b/pom.xml @@ -16,8 +16,8 @@ UTF-8 - 4.0.2.RELEASE - 1.4.3.RELEASE + 4.0.3.RELEASE + 1.5.1.RELEASE @@ -27,7 +27,7 @@ 2.2.7 - 4.3.3.Final + 4.3.5.Final 4.3.1.Final @@ -35,14 +35,14 @@ 7.0.42 2.6.8 - 2.3.1 + 2.3.2 1.7.4 - 1.1.1 - 1.7.6 + 1.1.2 + 1.7.7 1.0 @@ -55,7 +55,7 @@ 1.3 1.1.1 2.3 - 3.1.0.CR10 + 3.1.0.GA From ce7e6e8bdcc3b11571e3ada6b12ad9e5395b03f7 Mon Sep 17 00:00:00 2001 From: Mic Date: Sat, 12 Apr 2014 23:54:45 +0800 Subject: [PATCH 008/109] updated URL on cloud foundry --- pom.xml | 1 + readme.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c3d0c55e..b59ada728 100644 --- a/pom.xml +++ b/pom.xml @@ -455,4 +455,5 @@ + demopetclinic diff --git a/readme.md b/readme.md index c44602744..091f725cb 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ # Spring PetClinic Sample Application ## What does it look like? --spring-petclinic has been deployed here on cloudfoundry: http://gopetclinic.cfapps.io/ +-spring-petclinic has been deployed here on cloudfoundry: http://demo-spring-petclinic.cfapps.io/ ## Understanding the Spring Petclinic application with a few diagrams From 1341c12d1f20ec8cf9dc95d1e33398a19e55998b Mon Sep 17 00:00:00 2001 From: Bram Luyten Date: Sun, 11 May 2014 18:37:42 +0200 Subject: [PATCH 009/109] update db_readme.txt to reflect properties rename jdbc.properties was renamed to data-access.properties, but this file still referred to the old name. --- src/main/resources/db_readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db_readme.txt b/src/main/resources/db_readme.txt index 55fbb6264..68e3f245c 100644 --- a/src/main/resources/db_readme.txt +++ b/src/main/resources/db_readme.txt @@ -9,5 +9,5 @@ In its default configuration, Petclinic uses an in-memory database (HSQLDB) which gets populated at startup with data. A similar setup is provided for Mysql in case a persistent database configuration is needed. -Note that whenever the database type is changed, the jdbc.properties file needs to -be updated. \ No newline at end of file +Note that whenever the database type is changed, the data-access.properties file needs to +be updated. From e99c67a4bb7944062367d2f259fc6e1d11525cc9 Mon Sep 17 00:00:00 2001 From: Thibault Duchateau Date: Sat, 31 May 2014 11:02:32 +0200 Subject: [PATCH 010/109] Upgraded Dandelion-Datatables to the latest release (v0.10.0) * The old datatables-servlet2 dependency has been removed from the pom.xml * Some attributes have been renamed (e.g. paginate => pageable) * Starting from the v0.10.0, all web components (servlet, filter) must be explicitely declared in the web.xml file. That's why I added the following declaration: DandelionFilter, DandelionServlet and DatatablesFilter * Added a new datatables.properties file in order to disable the asset management brought by Dandelion-Core. This is equivalent to the old cdn=true table attribute --- pom.xml | 12 ++---- .../datatables/datatables.properties | 6 +++ .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 6 +-- src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 2 +- src/main/webapp/WEB-INF/web.xml | 41 +++++++++++-------- 5 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/main/resources/dandelion/datatables/datatables.properties diff --git a/pom.xml b/pom.xml index b59ada728..ea9b17a02 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ 2.3.0 1.10.3 2.0.3-1 - 0.9.3 + 0.10.0 5.1.22 @@ -303,19 +303,13 @@ com.github.dandelion datatables-jsp - ${dandelion.datatables.version} + ${dandelion.version} com.github.dandelion datatables-export-itext - ${dandelion.datatables.version} + ${dandelion.version} - - com.github.dandelion - datatables-servlet2 - ${dandelion.datatables.version} - - diff --git a/src/main/resources/dandelion/datatables/datatables.properties b/src/main/resources/dandelion/datatables/datatables.properties new file mode 100644 index 000000000..08b1e439c --- /dev/null +++ b/src/main/resources/dandelion/datatables/datatables.properties @@ -0,0 +1,6 @@ +# ================================== +# Dandelion-Datatables configuration +# ================================== + +# Disable the asset management of Dandelion-Core for all non-DataTable-related assets +main.standalone=true \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 6165782c0..9fb6704fa 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -15,8 +15,8 @@

Owners

- + @@ -34,7 +34,7 @@ - + diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index 07bbf636a..3f1e05b93 100644 --- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp +++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp @@ -16,7 +16,7 @@

Veterinarians

- + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index d9a3ac47d..360e3698a 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -58,17 +58,26 @@ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" / - + - datatablesController - com.github.dandelion.datatables.extras.servlet2.servlet.DatatablesServlet + dandelionServlet + com.github.dandelion.core.web.DandelionServlet + 2 - - - datatablesController - /datatablesController/* + dandelionServlet + /dandelion-assets/* + + + + dandelionFilter + com.github.dandelion.core.web.DandelionFilter + + + dandelionFilter + /* + - - datatablesFilter - com.github.dandelion.datatables.extras.servlet2.filter.DatatablesFilter - - - - - datatablesFilter + + + datatables + com.github.dandelion.datatables.core.web.filter.DatatablesFilter + + + datatables /* - + - 4.0.3.RELEASE - 1.5.1.RELEASE + 4.0.5.RELEASE + 1.6.0.RELEASE @@ -34,7 +34,7 @@ 7.0.42 - 2.6.8 + 2.6.9 2.3.2 From 9f6814d7db83596568de0825aa514a57a4f8e6a9 Mon Sep 17 00:00:00 2001 From: Mic Date: Wed, 2 Jul 2014 05:55:16 +0800 Subject: [PATCH 013/109] updated versions of Spring Data and AspectJ --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index cbc3501bf..e43175cf9 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.0.5.RELEASE - 1.6.0.RELEASE + 1.6.1.RELEASE @@ -38,7 +38,7 @@ 2.3.2 - 1.7.4 + 1.8.1 1.1.2 From de73bdce6bb7717a0a04fe99ffced0f30e133276 Mon Sep 17 00:00:00 2001 From: Craig Dennis Date: Mon, 7 Jul 2014 21:19:40 -0700 Subject: [PATCH 014/109] Fixed some typos in comments --- .../springframework/samples/petclinic/web/PetValidator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java index ad1ebdf81..03a1bca7c 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java @@ -29,19 +29,19 @@ public class PetValidator { public void validate(Pet pet, Errors errors) { String name = pet.getName(); - // name validaation + // name validation if (!StringUtils.hasLength(name)) { errors.rejectValue("name", "required", "required"); } else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) { errors.rejectValue("name", "duplicate", "already exists"); } - // type valication + // type validation if (pet.isNew() && pet.getType() == null) { errors.rejectValue("type", "required", "required"); } - // type valication + // birth date validation if (pet.getBirthDate()==null) { errors.rejectValue("birthDate", "required", "required"); } From df1596b78c408d2990cc4d409ea255938995d400 Mon Sep 17 00:00:00 2001 From: Mic Date: Fri, 8 Aug 2014 13:55:01 +0800 Subject: [PATCH 015/109] using latest versions of hibernate, spring-data, joda... --- .springBeans | 5 ++++- pom.xml | 44 +++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/.springBeans b/.springBeans index c4469cbf0..44f18becd 100644 --- a/.springBeans +++ b/.springBeans @@ -1,7 +1,7 @@ 1 - + @@ -12,6 +12,9 @@ src/main/resources/spring/mvc-view-config.xml src/main/resources/spring/business-config.xml + + src/main/resources/spring/tools-config.xml + diff --git a/pom.xml b/pom.xml index e43175cf9..4cece5266 100644 --- a/pom.xml +++ b/pom.xml @@ -16,8 +16,8 @@ UTF-8 - 4.0.5.RELEASE - 1.6.1.RELEASE + 4.0.6.RELEASE + 1.6.2.RELEASE @@ -27,7 +27,7 @@ 2.2.7 - 4.3.5.Final + 4.3.6.Final 4.3.1.Final @@ -54,8 +54,8 @@ 1.3 1.1.1 - 2.3 - 3.1.0.GA + 2.4 + 3.2.0.GA @@ -81,23 +81,23 @@ provided - javax.servlet.jsp - jsp-api - 2.1 - provided - + javax.servlet.jsp + jsp-api + 2.1 + provided + - - org.glassfish.web - jstl-impl - 1.2 - - - javax.servlet - servlet-api - - - + + org.glassfish.web + jstl-impl + 1.2 + + + javax.servlet + servlet-api + + + com.sun.xml.bind jaxb-impl @@ -310,9 +310,7 @@ datatables-export-itext ${dandelion.version} - - - 1.8.1 + 1.8.2 1.1.2 @@ -62,7 +62,7 @@ 2.3.0 1.10.3 2.0.3-1 - 0.10.0 + 0.10.1 5.1.22 From 74f683aaa94e8f3dd27bbcb1e9da0c62d02d3fd3 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Sat, 18 Oct 2014 22:13:01 +0800 Subject: [PATCH 017/109] Fixed typo --- .../samples/petclinic/repository/jdbc/JdbcPet.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java index b548629c7..f2ed25823 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java @@ -18,11 +18,10 @@ package org.springframework.samples.petclinic.repository.jdbc; import org.springframework.samples.petclinic.model.Pet; /** - * Subclass of Pet that carries temporary id properties which are only relevant for a JDBC implmentation of the + * Subclass of Pet that carries temporary id properties which are only relevant for a JDBC implementation of the * ClinicService. * * @author Juergen Hoeller - * @see JdbcClinicImpl */ class JdbcPet extends Pet { From f5cf426e435ee3fcb11f6df2c41d420922de2aff Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Sat, 18 Oct 2014 22:28:30 +0800 Subject: [PATCH 018/109] upgraded to Joda Time 2.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86181d8f1..78b70c595 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ 1.3 1.1.1 - 2.4 + 2.5 3.2.0.GA From 475f5f534910aa2bff5563eab9c4eec486430e48 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Sat, 18 Oct 2014 23:36:15 +0800 Subject: [PATCH 019/109] migrated to Spring 4.1.1.RELEASE Also had to make changes because Spring now uses com.rometools for RSS feeds See here for more details: https://jira.spring.io/browse/SPR-11893 --- pom.xml | 6 +++--- .../samples/petclinic/web/VetsAtomView.java | 19 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 78b70c595..5b3b1eab2 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ UTF-8 - 4.0.6.RELEASE + 4.1.1.RELEASE 1.6.2.RELEASE @@ -45,7 +45,7 @@ 1.7.7 - 1.0 + 1.5.0 4.11 @@ -187,7 +187,7 @@ - rome + com.rometools rome ${rome.version} diff --git a/src/main/java/org/springframework/samples/petclinic/web/VetsAtomView.java b/src/main/java/org/springframework/samples/petclinic/web/VetsAtomView.java index 3de619ac4..bf26c3900 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/VetsAtomView.java +++ b/src/main/java/org/springframework/samples/petclinic/web/VetsAtomView.java @@ -15,20 +15,19 @@ */ package org.springframework.samples.petclinic.web; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import com.rometools.rome.feed.atom.Entry; +import com.rometools.rome.feed.atom.Feed; +import com.rometools.rome.feed.atom.Content; import org.springframework.samples.petclinic.model.Vet; import org.springframework.samples.petclinic.model.Vets; import org.springframework.web.servlet.view.feed.AbstractAtomFeedView; -import com.sun.syndication.feed.atom.Content; -import com.sun.syndication.feed.atom.Entry; -import com.sun.syndication.feed.atom.Feed; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + /** * A view creating a Atom representation from a list of Visit objects. From 8929d373ec384c1e022f7336b69aa7bbcd995b83 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Sat, 18 Oct 2014 23:39:29 +0800 Subject: [PATCH 020/109] upgraded to Spring Data 1.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b3b1eab2..a1fd6e3e8 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.1.1.RELEASE - 1.6.2.RELEASE + 1.7.0.RELEASE From 92e7ab43be740bde896b1a6738535f61bb341b49 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Fri, 28 Nov 2014 12:45:57 +0900 Subject: [PATCH 021/109] Simplified ContentNegoViewResolver config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Now using namespace, much simpler (11 lines instead of 27) - Just a minor issue with: (should investigate later if we can remove “url” attribute --- src/main/resources/spring/mvc-view-config.xml | 56 ++++++------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/src/main/resources/spring/mvc-view-config.xml b/src/main/resources/spring/mvc-view-config.xml index 4413f0195..205f7ffce 100644 --- a/src/main/resources/spring/mvc-view-config.xml +++ b/src/main/resources/spring/mvc-view-config.xml @@ -2,51 +2,31 @@ - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - From f0bf6927674a8c4fdf5a74352749ca5be326b5d3 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Fri, 28 Nov 2014 13:19:25 +0900 Subject: [PATCH 022/109] Moving "visit" object to request scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously was in session scope (doesn’t scale as well) --- .../petclinic/web/VisitController.java | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/VisitController.java b/src/main/java/org/springframework/samples/petclinic/web/VisitController.java index 4f38bd574..f3f6f3ffb 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/VisitController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/VisitController.java @@ -27,12 +27,10 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.SessionAttributes; -import org.springframework.web.bind.support.SessionStatus; -import org.springframework.web.servlet.ModelAndView; /** * @author Juergen Hoeller @@ -41,7 +39,6 @@ import org.springframework.web.servlet.ModelAndView; * @author Michael Isvy */ @Controller -@SessionAttributes("visit") public class VisitController { private final ClinicService clinicService; @@ -56,32 +53,45 @@ public class VisitController { public void setAllowedFields(WebDataBinder dataBinder) { dataBinder.setDisallowedFields("id"); } - - @RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET) - public String initNewVisitForm(@PathVariable("petId") int petId, Map model) { + + /** + * Called before each and every @RequestMapping annotated method. + * 2 goals: + * - Make sure we always have fresh data + * - Since we do not use the session scope, make sure that Pet object always has an id + * (Even though id is not part of the form fields) + * @param petId + * @return Pet + */ + @ModelAttribute("visit") + public Visit loadPetWithVisit(@PathVariable("petId") int petId) { Pet pet = this.clinicService.findPetById(petId); Visit visit = new Visit(); - pet.addVisit(visit); - model.put("visit", visit); + pet.addVisit(visit); + return visit; + } + + // Spring MVC calls method loadPetWithVisit(...) before initNewVisitForm is called + @RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET) + public String initNewVisitForm(@PathVariable("petId") int petId, Map model) { return "pets/createOrUpdateVisitForm"; } + // Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called @RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST) - public String processNewVisitForm(@Valid Visit visit, BindingResult result, SessionStatus status) { + public String processNewVisitForm(@Valid Visit visit, BindingResult result) { if (result.hasErrors()) { return "pets/createOrUpdateVisitForm"; } else { this.clinicService.saveVisit(visit); - status.setComplete(); return "redirect:/owners/{ownerId}"; } } @RequestMapping(value = "/owners/*/pets/{petId}/visits", method = RequestMethod.GET) - public ModelAndView showVisits(@PathVariable int petId) { - ModelAndView mav = new ModelAndView("visitList"); - mav.addObject("visits", this.clinicService.findPetById(petId).getVisits()); - return mav; + public String showVisits(@PathVariable int petId, Map model) { + model.put("visits", this.clinicService.findPetById(petId).getVisits()); + return "visitList"; } } From 6e079b23bbda78335f814b9f06436398d5baa0f1 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Fri, 28 Nov 2014 13:25:17 +0900 Subject: [PATCH 023/109] Error control on description was missing Took that opportunity to use custom tag (14 lines versus 2 lines) --- .../jsp/pets/createOrUpdateVisitForm.jsp | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp index 4c65be890..4fe164820 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp @@ -5,6 +5,8 @@ <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %> +<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> + @@ -40,22 +42,10 @@ -
- - -
- - -
-
-
- - -
- - -
-
+ + + +
From 85c8237fb5f7e3924ec43a7677e2233ae6e6ae24 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Fri, 28 Nov 2014 13:40:46 +0900 Subject: [PATCH 024/109] added comment on --- src/main/resources/spring/mvc-core-config.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/resources/spring/mvc-core-config.xml b/src/main/resources/spring/mvc-core-config.xml index 170fbdba1..eab2062dc 100644 --- a/src/main/resources/spring/mvc-core-config.xml +++ b/src/main/resources/spring/mvc-core-config.xml @@ -33,8 +33,9 @@ - - + + From 49c39b65dca6f83c3dd9fdb6e2481766f4fccd97 Mon Sep 17 00:00:00 2001 From: michaelisvy Date: Fri, 28 Nov 2014 13:52:09 +0900 Subject: [PATCH 025/109] renamed headTag.jsp -> staticFiles.jsp --- src/main/webapp/WEB-INF/jsp/exception.jsp | 2 +- .../WEB-INF/jsp/fragments/{headTag.jsp => staticFiles.jsp} | 0 src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp | 2 +- src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp | 2 +- src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp | 2 +- src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp | 2 +- src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp | 2 +- src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp | 2 +- src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 2 +- src/main/webapp/WEB-INF/jsp/welcome.jsp | 2 +- 10 files changed, 9 insertions(+), 9 deletions(-) rename src/main/webapp/WEB-INF/jsp/fragments/{headTag.jsp => staticFiles.jsp} (100%) diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp index f7aa16f97..876fb04a3 100644 --- a/src/main/webapp/WEB-INF/jsp/exception.jsp +++ b/src/main/webapp/WEB-INF/jsp/exception.jsp @@ -4,7 +4,7 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - +
diff --git a/src/main/webapp/WEB-INF/jsp/fragments/headTag.jsp b/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp similarity index 100% rename from src/main/webapp/WEB-INF/jsp/fragments/headTag.jsp rename to src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index 18d45cffd..0479f0bde 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -10,7 +10,7 @@ - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index a41d07956..91d2ebabc 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -7,7 +7,7 @@ - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 0cb449dd1..4ace4ba23 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -8,7 +8,7 @@ - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 9fb6704fa..5e8eaaaaa 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -8,7 +8,7 @@ - +
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index 6a740609c..c41f02ddf 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp @@ -8,7 +8,7 @@ - +
- - - - - - - -

New Pet

-
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index bd3ea6d4a..7bb52a0c1 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -98,19 +98,6 @@ /* - - - httpMethodFilter - org.springframework.web.filter.HiddenHttpMethodFilter - - - - httpMethodFilter - petclinic - - datatables From cb0504ee976720d6759b91b747ea4cd88f9ba9ab Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 13 Oct 2015 08:32:15 +0200 Subject: [PATCH 094/109] #92 add some comments to switch from HSQLDB to MySQL --- pom.xml | 9 +++++++- readme.md | 13 ++++++++++++ src/main/resources/db_readme.txt | 13 ------------ .../resources/spring/data-access.properties | 21 +++++++------------ 4 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 src/main/resources/db_readme.txt diff --git a/pom.xml b/pom.xml index 2ffe282a0..3e56f09b5 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,8 @@ 1.1.1 3.2.0.GA + + 5.1.36 2.3.0 @@ -189,7 +191,12 @@ - + + org.hibernate diff --git a/readme.md b/readme.md index a314398a2..8c84871da 100644 --- a/readme.md +++ b/readme.md @@ -15,6 +15,19 @@ You can then access petclinic here: http://localhost:9966/petclinic/ ## In case you find a bug/suggested improvement for Spring Petclinic Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues + +## Database configuration + +In its default configuration, Petclinic uses an in-memory database (HSQLDB) which +gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed. +Note that whenever the database type is changed, the data-access.properties file needs to be updated and the mysql-connector-java artifact from the pom.xml needs to be uncommented. + +You may start a MySql database with docker: + +``` +docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8 +``` + ## Working with Petclinic in Eclipse/STS ### prerequisites diff --git a/src/main/resources/db_readme.txt b/src/main/resources/db_readme.txt deleted file mode 100644 index 68e3f245c..000000000 --- a/src/main/resources/db_readme.txt +++ /dev/null @@ -1,13 +0,0 @@ -================================================================================ -=== Spring PetClinic sample application - Database Configuration === -================================================================================ - -@author Costin Leau - --------------------------------------------------------------------------------- - -In its default configuration, Petclinic uses an in-memory database (HSQLDB) which -gets populated at startup with data. A similar setup is provided for Mysql in case -a persistent database configuration is needed. -Note that whenever the database type is changed, the data-access.properties file needs to -be updated. diff --git a/src/main/resources/spring/data-access.properties b/src/main/resources/spring/data-access.properties index c1cc3cefd..e154d81db 100644 --- a/src/main/resources/spring/data-access.properties +++ b/src/main/resources/spring/data-access.properties @@ -4,6 +4,12 @@ # various application context XML files (e.g., "applicationContext-*.xml"). # Targeted at system administrators, to avoid touching the context XML files. +# Properties that control the population of schema and data for a new data source +jdbc.initLocation=classpath:db/hsqldb/initDB.sql +jdbc.dataLocation=classpath:db/hsqldb/populateDB.sql + +jpa.showSql=true + #------------------------------------------------------------------------------- # HSQL Settings @@ -12,14 +18,9 @@ jdbc.url=jdbc:hsqldb:mem:petclinic jdbc.username=sa jdbc.password= -# Properties that control the population of schema and data for a new data source -jdbc.initLocation=classpath:db/hsqldb/initDB.sql -jdbc.dataLocation=classpath:db/hsqldb/populateDB.sql - # Property that determines which database to use with an AbstractJpaVendorAdapter jpa.database=HSQL -jpa.showSql=true #------------------------------------------------------------------------------- # MySQL Settings @@ -27,15 +28,7 @@ jpa.showSql=true #jdbc.driverClassName=com.mysql.jdbc.Driver #jdbc.url=jdbc:mysql://localhost:3306/petclinic #jdbc.username=root -#jdbc.password= - -# Properties that control the population of schema and data for a new data source -#jdbc.initLocation=classpath:db/mysql/initDB.sql -#jdbc.dataLocation=classpath:db/mysql/populateDB.sql - -# Property that determines which Hibernate dialect to use -# (only applied with "applicationContext-hibernate.xml") -#hibernate.dialect=org.hibernate.dialect.MySQLDialect +#jdbc.password=petclinic # Property that determines which database to use with an AbstractJpaVendorAdapter #jpa.database=MYSQL From 4bb829cbd1026ec10dc685277467d30523c90b95 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 13 Oct 2015 18:41:18 +0200 Subject: [PATCH 095/109] Fix #101 display the pet type when using the JDBC profile --- .../petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java | 3 +++ .../springframework/samples/petclinic/web/PetValidator.java | 2 +- .../samples/petclinic/service/AbstractClinicServiceTests.java | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java index 0a471b4d8..7103dc470 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java @@ -35,6 +35,7 @@ import org.springframework.samples.petclinic.model.Pet; import org.springframework.samples.petclinic.model.PetType; import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.repository.OwnerRepository; +import org.springframework.samples.petclinic.util.EntityUtils; import org.springframework.stereotype.Repository; /** @@ -114,7 +115,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository { params, new JdbcPetVisitExtractor() ); + Collection petTypes = getPetTypes(); for (JdbcPet pet : pets) { + pet.setType(EntityUtils.getById(petTypes, PetType.class, pet.getTypeId())); owner.addPet(pet); } } diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java index 0621c98ab..5784278b9 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java @@ -58,7 +58,7 @@ public class PetValidator implements Validator { */ @Override public boolean supports(Class clazz) { - return Pet.class.equals(clazz); + return Pet.class.isAssignableFrom(clazz); } diff --git a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java index 428c285fd..473acdc6e 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java @@ -69,6 +69,8 @@ public abstract class AbstractClinicServiceTests { Owner owner = this.clinicService.findOwnerById(1); assertThat(owner.getLastName()).startsWith("Franklin"); assertThat(owner.getPets().size()).isEqualTo(1); + assertThat(owner.getPets().get(0).getType()).isNotNull(); + assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat"); } @Test From 8b5d980416a3462ca14bc43932f550ac0f532941 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 14 Oct 2015 08:29:28 +0200 Subject: [PATCH 096/109] Fix #95 migrate to AssertJ 3.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e56f09b5..7ec264dec 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 7.0.59 - 2.1.0 + 3.2.0 1.3 From 1aef94d6a86634f810b1eae448d4e2594eac54f6 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 16 Oct 2015 08:03:19 +0200 Subject: [PATCH 097/109] #95 Downgrade to AssertJ 2.2.0 to be compatible with Java 7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ec264dec..504e97c35 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 7.0.59 - 3.2.0 + 2.2.0 1.3 From 09ed33a5fc01209b4190c74f405b2b1e523b739c Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 16 Oct 2015 09:33:06 +0200 Subject: [PATCH 098/109] #96 Reformat code with EditorConfig --- .editorconfig | 9 + pom.xml | 745 +++++++++--------- .../samples/petclinic/model/BaseEntity.java | 7 +- .../samples/petclinic/model/NamedEntity.java | 7 +- .../samples/petclinic/model/Owner.java | 24 +- .../samples/petclinic/model/Pet.java | 21 +- .../samples/petclinic/model/PetType.java | 2 +- .../samples/petclinic/model/Vet.java | 11 +- .../samples/petclinic/model/package-info.java | 3 - .../petclinic/repository/OwnerRepository.java | 5 +- .../petclinic/repository/PetRepository.java | 3 +- .../jdbc/JdbcOwnerRepositoryImpl.java | 32 +- .../petclinic/repository/jdbc/JdbcPet.java | 13 +- .../jdbc/JdbcPetRepositoryImpl.java | 34 +- .../jdbc/JdbcPetVisitExtractor.java | 4 +- .../jdbc/JdbcVetRepositoryImpl.java | 24 +- .../jdbc/JdbcVisitRepositoryImpl.java | 18 +- .../repository/jdbc/package-info.java | 3 - .../jpa/JpaOwnerRepositoryImpl.java | 13 +- .../repository/jpa/JpaPetRepositoryImpl.java | 11 +- .../jpa/JpaVisitRepositoryImpl.java | 11 +- .../repository/jpa/package-info.java | 3 - .../SpringDataOwnerRepository.java | 16 +- .../petclinic/util/CallMonitoringAspect.java | 23 +- .../samples/petclinic/util/EntityUtils.java | 5 +- .../petclinic/web/CrashController.java | 2 +- .../petclinic/web/OwnerController.java | 14 +- .../samples/petclinic/web/PetValidator.java | 6 +- .../samples/petclinic/web/VetController.java | 12 +- .../petclinic/web/VisitController.java | 19 +- .../samples/petclinic/web/package-info.java | 3 - src/main/java/test.html | 76 +- src/main/resources/logback.xml | 4 +- src/main/resources/spring/business-config.xml | 36 +- .../resources/spring/datasource-config.xml | 8 +- src/main/resources/spring/mvc-core-config.xml | 14 +- src/main/resources/spring/mvc-view-config.xml | 32 +- src/main/resources/spring/tools-config.xml | 6 +- src/main/webapp/WEB-INF/jsp/exception.jsp | 2 +- .../WEB-INF/jsp/fragments/bodyHeader.jsp | 2 +- .../WEB-INF/jsp/fragments/staticFiles.jsp | 6 +- .../jsp/owners/createOrUpdateOwnerForm.jsp | 2 +- .../webapp/WEB-INF/jsp/owners/findOwners.jsp | 2 +- .../WEB-INF/jsp/owners/ownerDetails.jsp | 38 +- .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 10 +- .../jsp/pets/createOrUpdatePetForm.jsp | 4 +- .../jsp/pets/createOrUpdateVisitForm.jsp | 12 +- src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 7 +- src/main/webapp/WEB-INF/jsp/welcome.jsp | 2 +- src/main/webapp/WEB-INF/web.xml | 86 +- .../petclinic/model/ValidatorTests.java | 26 +- .../service/AbstractClinicServiceTests.java | 158 ++-- .../service/ClinicServiceJdbcTests.java | 4 +- .../service/ClinicServiceJpaTests.java | 7 +- .../ClinicServiceSpringDataJpaTests.java | 8 +- .../petclinic/web/VetControllerTests.java | 8 +- 56 files changed, 831 insertions(+), 832 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..de9af4689 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# top-most EditorConfig file +root = true + +[*.{java,xml}] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/pom.xml b/pom.xml index 504e97c35..d4c16ce5b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,406 +1,407 @@ - - 4.0.0 - org.springframework.samples - spring-petclinic - 1.0.0-SNAPSHOT + + 4.0.0 + org.springframework.samples + spring-petclinic + 1.0.0-SNAPSHOT - petclinic - war + petclinic + war - + - - 1.7 - UTF-8 - UTF-8 + + 1.7 + UTF-8 + UTF-8 - - 1.1.3.RELEASE - 1.1.0.RELEASE + + 1.1.3.RELEASE + 1.1.0.RELEASE - - 7.0.59 + + 7.0.59 - - 2.2.0 - - - 1.3 - 1.1.1 - 3.2.0.GA + + 2.2.0 - - 5.1.36 + + 1.3 + 1.1.1 + 3.2.0.GA - - 2.3.0 - 1.10.3 - 2.0.3-1 - 1.0.1 + + 5.1.36 - 2.7 + + 2.3.0 + 1.10.3 + 2.0.3-1 + 1.0.1 - + 2.7 - - - - - io.spring.platform - platform-bom - ${spring-io-platform.version} - pom - import - - - + - - - org.jadira.usertype - usertype.core - ${jadira-usertype-core.version} - - - org.apache.tomcat - tomcat-servlet-api - ${tomcat.version} - provided + + + + + io.spring.platform + platform-bom + ${spring-io-platform.version} + pom + import + + + + + + + org.jadira.usertype + usertype.core + ${jadira-usertype-core.version} + + + org.apache.tomcat + tomcat-servlet-api + ${tomcat.version} + provided + + + javax.servlet.jsp + javax.servlet.jsp-api + provided + + + org.apache.tomcat + tomcat-jasper-el + ${tomcat.version} + provided - - javax.servlet.jsp - javax.servlet.jsp-api - provided - - - org.apache.tomcat - tomcat-jasper-el - ${tomcat.version} - provided - - javax.servlet.jsp.jstl - javax.servlet.jsp.jstl-api + javax.servlet.jsp.jstl + javax.servlet.jsp.jstl-api - - org.apache.taglibs - taglibs-standard-jstlel - - - + + org.apache.taglibs + taglibs-standard-jstlel + + + com.jayway.jsonpath json-path test - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-data-jpa - + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-data-jpa + - - org.springframework.data - spring-data-jdbc-core - ${spring-data-jdbc.version} - - - org.springframework - * - - - - + + org.springframework.data + spring-data-jdbc-core + ${spring-data-jdbc.version} + + + org.springframework + * + + + + - - org.springframework - spring-jdbc - - - org.springframework - spring-webmvc - - - - org.springframework - spring-context-support - - - org.springframework - spring-oxm - + + org.springframework + spring-jdbc + + + org.springframework + spring-webmvc + + + + org.springframework + spring-context-support + + + org.springframework + spring-oxm + - - org.aspectj - aspectjrt - - - org.aspectj - aspectjweaver - runtime - - - - - org.apache.tomcat - tomcat-jdbc - runtime - + + org.apache.tomcat + tomcat-jdbc + runtime + - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - runtime - - - - - joda-time - joda-time - - - joda-time - joda-time-hibernate - ${jodatime-hibernate.version} - - - joda-time - joda-time-jsptags - ${jodatime-jsptags.version} - + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + runtime + - - - org.hsqldb - hsqldb - runtime - + + + joda-time + joda-time + + + joda-time + joda-time-hibernate + ${jodatime-hibernate.version} + + + joda-time + joda-time-jsptags + ${jodatime-jsptags.version} + - - + + + org.hsqldb + hsqldb + runtime + - - - org.hibernate - hibernate-entitymanager - - - org.hibernate - hibernate-validator - - - - org.hibernate - hibernate-ehcache - - - net.sf.ehcache - ehcache-core - - - commons-logging - commons-logging - - - - - - org.webjars - bootstrap - ${webjars-bootstrap.version} - - - org.webjars - jquery-ui - ${webjars-jquery-ui.version} - - - org.webjars - jquery - ${webjars-jquery.version} - - - - - org.springframework - spring-test - test - - - junit - junit - test - - - org.assertj - assertj-core - ${assertj.version} - test - + + - - - com.github.dandelion - datatables-jsp - ${dandelion.version} - - - com.github.dandelion - datatables-export-itext - ${dandelion.version} - - - - com.googlecode.json-simple - json-simple - - + + + org.hibernate + hibernate-entitymanager + + + org.hibernate + hibernate-validator + - - - install - - - - ${project.basedir}/src/test/java - - - ${project.basedir}/src/test/resources - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - - - - true - ${java.version} - ${java.version} - true - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.13 - - - **/*Tests.java - - - - - org.apache.maven.plugins - maven-war-plugin - 2.3 - - petclinic - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - true - true - 2.0 - - **/*.* - - - - org.springframework.ide.eclipse.core.springbuilder - - - org.eclipse.m2e.core.maven2Builder - - - - org.eclipse.jdt.core.javanature - org.springframework.ide.eclipse.core.springnature - org.eclipse.m2e.core.maven2Nature - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.4 - - - jar-with-dependencies - - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - tomcat-development-server - 9966 - /petclinic - - - - org.codehaus.mojo - cobertura-maven-plugin - ${cobertura.version} - - - - - - - clean - check - - - - - - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - ${cobertura.version} - - - html - - - - - - + + org.hibernate + hibernate-ehcache + + + net.sf.ehcache + ehcache-core + + + commons-logging + commons-logging + + + + + + org.webjars + bootstrap + ${webjars-bootstrap.version} + + + org.webjars + jquery-ui + ${webjars-jquery-ui.version} + + + org.webjars + jquery + ${webjars-jquery.version} + - demopetclinic + + + org.springframework + spring-test + test + + + junit + junit + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + com.github.dandelion + datatables-jsp + ${dandelion.version} + + + com.github.dandelion + datatables-export-itext + ${dandelion.version} + + + + com.googlecode.json-simple + json-simple + + + + + + install + + + + ${project.basedir}/src/test/java + + + ${project.basedir}/src/test/resources + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + + true + ${java.version} + ${java.version} + true + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.13 + + + **/*Tests.java + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + petclinic + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.9 + + true + true + 2.0 + + **/*.* + + + + org.springframework.ide.eclipse.core.springbuilder + + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.springframework.ide.eclipse.core.springnature + org.eclipse.m2e.core.maven2Nature + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4 + + + jar-with-dependencies + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + tomcat-development-server + 9966 + /petclinic + + + + org.codehaus.mojo + cobertura-maven-plugin + ${cobertura.version} + + + + + + + clean + check + + + + + + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + ${cobertura.version} + + + html + + + + + + + + demopetclinic diff --git a/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java b/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java index 8dfbfe90b..55b470e1e 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java +++ b/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java @@ -32,15 +32,14 @@ public class BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) protected Integer id; + public Integer getId() { + return id; + } public void setId(Integer id) { this.id = id; } - public Integer getId() { - return id; - } - public boolean isNew() { return (this.id == null); } diff --git a/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java b/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java index cb36a6267..d66c97ae7 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java +++ b/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java @@ -32,15 +32,14 @@ public class NamedEntity extends BaseEntity { @Column(name = "name") private String name; + public String getName() { + return this.name; + } public void setName(String name) { this.name = name; } - public String getName() { - return this.name; - } - @Override public String toString() { return this.getName(); diff --git a/src/main/java/org/springframework/samples/petclinic/model/Owner.java b/src/main/java/org/springframework/samples/petclinic/model/Owner.java index ca7c97ec2..d0158d907 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Owner.java @@ -85,10 +85,6 @@ public class Owner extends Person { this.telephone = telephone; } - protected void setPetsInternal(Set pets) { - this.pets = pets; - } - protected Set getPetsInternal() { if (this.pets == null) { this.pets = new HashSet<>(); @@ -96,6 +92,10 @@ public class Owner extends Person { return this.pets; } + protected void setPetsInternal(Set pets) { + this.pets = pets; + } + public List getPets() { List sortedPets = new ArrayList<>(getPetsInternal()); PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true)); @@ -141,13 +141,13 @@ public class Owner extends Person { public String toString() { return new ToStringCreator(this) - .append("id", this.getId()) - .append("new", this.isNew()) - .append("lastName", this.getLastName()) - .append("firstName", this.getFirstName()) - .append("address", this.address) - .append("city", this.city) - .append("telephone", this.telephone) - .toString(); + .append("id", this.getId()) + .append("new", this.isNew()) + .append("lastName", this.getLastName()) + .append("firstName", this.getFirstName()) + .append("address", this.address) + .append("city", this.city) + .append("telephone", this.telephone) + .toString(); } } diff --git a/src/main/java/org/springframework/samples/petclinic/model/Pet.java b/src/main/java/org/springframework/samples/petclinic/model/Pet.java index 536fe07e6..09eeb769e 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Pet.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Pet.java @@ -63,33 +63,28 @@ public class Pet extends NamedEntity { @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER) private Set visits; - - public void setBirthDate(DateTime birthDate) { - this.birthDate = birthDate; - } - public DateTime getBirthDate() { return this.birthDate; } - public void setType(PetType type) { - this.type = type; + public void setBirthDate(DateTime birthDate) { + this.birthDate = birthDate; } public PetType getType() { return this.type; } - protected void setOwner(Owner owner) { - this.owner = owner; + public void setType(PetType type) { + this.type = type; } public Owner getOwner() { return this.owner; } - protected void setVisitsInternal(Set visits) { - this.visits = visits; + protected void setOwner(Owner owner) { + this.owner = owner; } protected Set getVisitsInternal() { @@ -99,6 +94,10 @@ public class Pet extends NamedEntity { return this.visits; } + protected void setVisitsInternal(Set visits) { + this.visits = visits; + } + public List getVisits() { List sortedVisits = new ArrayList<>(getVisitsInternal()); PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false)); diff --git a/src/main/java/org/springframework/samples/petclinic/model/PetType.java b/src/main/java/org/springframework/samples/petclinic/model/PetType.java index 99adf7591..f60a5cd27 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/PetType.java +++ b/src/main/java/org/springframework/samples/petclinic/model/PetType.java @@ -20,7 +20,7 @@ import javax.persistence.Table; /** * @author Juergen Hoeller - * Can be Cat, Dog, Hamster... + * Can be Cat, Dog, Hamster... */ @Entity @Table(name = "types") diff --git a/src/main/java/org/springframework/samples/petclinic/model/Vet.java b/src/main/java/org/springframework/samples/petclinic/model/Vet.java index 61c518786..d93e14c46 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Vet.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Vet.java @@ -46,14 +46,9 @@ public class Vet extends Person { @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), - inverseJoinColumns = @JoinColumn(name = "specialty_id")) + inverseJoinColumns = @JoinColumn(name = "specialty_id")) private Set specialties; - - protected void setSpecialtiesInternal(Set specialties) { - this.specialties = specialties; - } - protected Set getSpecialtiesInternal() { if (this.specialties == null) { this.specialties = new HashSet<>(); @@ -61,6 +56,10 @@ public class Vet extends Person { return this.specialties; } + protected void setSpecialtiesInternal(Set specialties) { + this.specialties = specialties; + } + @XmlElement public List getSpecialties() { List sortedSpecs = new ArrayList<>(getSpecialtiesInternal()); diff --git a/src/main/java/org/springframework/samples/petclinic/model/package-info.java b/src/main/java/org/springframework/samples/petclinic/model/package-info.java index 2723dc9ab..2730958db 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/model/package-info.java @@ -1,8 +1,5 @@ - /** - * * The classes in this package represent PetClinic's business layer. - * */ package org.springframework.samples.petclinic.model; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java index 131833706..a273a1f7f 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java @@ -53,7 +53,7 @@ public interface OwnerRepository { * * @param lastName Value to search for * @return a Collection of matching Owners (or an empty Collection if none - * found) + * found) */ Collection findByLastName(String lastName) throws DataAccessException; @@ -62,8 +62,7 @@ public interface OwnerRepository { * * @param id the id to search for * @return the Owner if found - * @throws org.springframework.dao.DataRetrievalFailureException - * if not found + * @throws org.springframework.dao.DataRetrievalFailureException if not found */ Owner findById(int id) throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java index 693b2e5e9..1770e8555 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java @@ -45,8 +45,7 @@ public interface PetRepository { * * @param id the id to search for * @return the Pet if found - * @throws org.springframework.dao.DataRetrievalFailureException - * if not found + * @throws org.springframework.dao.DataRetrievalFailureException if not found */ Pet findById(int id) throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java index 7103dc470..45de1aee0 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java @@ -59,8 +59,8 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository { public JdbcOwnerRepositoryImpl(DataSource dataSource, NamedParameterJdbcTemplate namedParameterJdbcTemplate) { this.insertOwner = new SimpleJdbcInsert(dataSource) - .withTableName("owners") - .usingGeneratedKeyColumns("id"); + .withTableName("owners") + .usingGeneratedKeyColumns("id"); this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); @@ -77,9 +77,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository { Map params = new HashMap<>(); params.put("lastName", lastName + "%"); List owners = this.namedParameterJdbcTemplate.query( - "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName", - params, - BeanPropertyRowMapper.newInstance(Owner.class) + "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName", + params, + BeanPropertyRowMapper.newInstance(Owner.class) ); loadOwnersPetsAndVisits(owners); return owners; @@ -96,9 +96,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository { Map params = new HashMap<>(); params.put("id", id); owner = this.namedParameterJdbcTemplate.queryForObject( - "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id", - params, - BeanPropertyRowMapper.newInstance(Owner.class) + "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id", + params, + BeanPropertyRowMapper.newInstance(Owner.class) ); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(Owner.class, id); @@ -111,9 +111,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository { Map params = new HashMap<>(); params.put("id", owner.getId()); final List pets = this.namedParameterJdbcTemplate.query( - "SELECT pets.id, name, birth_date, type_id, owner_id, visits.id as visit_id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id", - params, - new JdbcPetVisitExtractor() + "SELECT pets.id, name, birth_date, type_id, owner_id, visits.id as visit_id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id", + params, + new JdbcPetVisitExtractor() ); Collection petTypes = getPetTypes(); for (JdbcPet pet : pets) { @@ -130,16 +130,16 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository { owner.setId(newKey.intValue()); } else { this.namedParameterJdbcTemplate.update( - "UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, " + - "city=:city, telephone=:telephone WHERE id=:id", - parameterSource); + "UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, " + + "city=:city, telephone=:telephone WHERE id=:id", + parameterSource); } } public Collection getPetTypes() throws DataAccessException { return this.namedParameterJdbcTemplate.query( - "SELECT id, name FROM types ORDER BY name", new HashMap(), - BeanPropertyRowMapper.newInstance(PetType.class)); + "SELECT id, name FROM types ORDER BY name", new HashMap(), + BeanPropertyRowMapper.newInstance(PetType.class)); } /** diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java index 39ba53b83..4c266b931 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java @@ -29,21 +29,20 @@ class JdbcPet extends Pet { private int ownerId; - - public void setTypeId(int typeId) { - this.typeId = typeId; - } - public int getTypeId() { return this.typeId; } - public void setOwnerId(int ownerId) { - this.ownerId = ownerId; + public void setTypeId(int typeId) { + this.typeId = typeId; } public int getOwnerId() { return this.ownerId; } + public void setOwnerId(int ownerId) { + this.ownerId = ownerId; + } + } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java index e3c02fc93..885c2bc2f 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java @@ -64,8 +64,8 @@ public class JdbcPetRepositoryImpl implements PetRepository { this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); this.insertPet = new SimpleJdbcInsert(dataSource) - .withTableName("pets") - .usingGeneratedKeyColumns("id"); + .withTableName("pets") + .usingGeneratedKeyColumns("id"); this.ownerRepository = ownerRepository; this.visitRepository = visitRepository; @@ -75,9 +75,9 @@ public class JdbcPetRepositoryImpl implements PetRepository { public List findPetTypes() throws DataAccessException { Map params = new HashMap<>(); return this.namedParameterJdbcTemplate.query( - "SELECT id, name FROM types ORDER BY name", - params, - BeanPropertyRowMapper.newInstance(PetType.class)); + "SELECT id, name FROM types ORDER BY name", + params, + BeanPropertyRowMapper.newInstance(PetType.class)); } @Override @@ -87,9 +87,9 @@ public class JdbcPetRepositoryImpl implements PetRepository { Map params = new HashMap<>(); params.put("id", id); pet = this.namedParameterJdbcTemplate.queryForObject( - "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id", - params, - new JdbcPetRowMapper()); + "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id", + params, + new JdbcPetRowMapper()); } catch (EmptyResultDataAccessException ex) { throw new ObjectRetrievalFailureException(Pet.class, id); } @@ -108,13 +108,13 @@ public class JdbcPetRepositoryImpl implements PetRepository { public void save(Pet pet) throws DataAccessException { if (pet.isNew()) { Number newKey = this.insertPet.executeAndReturnKey( - createPetParameterSource(pet)); + createPetParameterSource(pet)); pet.setId(newKey.intValue()); } else { this.namedParameterJdbcTemplate.update( - "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " + - "owner_id=:owner_id WHERE id=:id", - createPetParameterSource(pet)); + "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " + + "owner_id=:owner_id WHERE id=:id", + createPetParameterSource(pet)); } } @@ -123,11 +123,11 @@ public class JdbcPetRepositoryImpl implements PetRepository { */ private MapSqlParameterSource createPetParameterSource(Pet pet) { return new MapSqlParameterSource() - .addValue("id", pet.getId()) - .addValue("name", pet.getName()) - .addValue("birth_date", pet.getBirthDate().toDate()) - .addValue("type_id", pet.getType().getId()) - .addValue("owner_id", pet.getOwner().getId()); + .addValue("id", pet.getId()) + .addValue("name", pet.getName()) + .addValue("birth_date", pet.getBirthDate().toDate()) + .addValue("type_id", pet.getType().getId()) + .addValue("owner_id", pet.getOwner().getId()); } } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetVisitExtractor.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetVisitExtractor.java index c40786d93..6a4ba62c3 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetVisitExtractor.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetVisitExtractor.java @@ -27,7 +27,7 @@ import java.sql.SQLException; * {@link OneToManyResultSetExtractor} of Spring Data Core JDBC Extensions. */ public class JdbcPetVisitExtractor extends - OneToManyResultSetExtractor { + OneToManyResultSetExtractor { public JdbcPetVisitExtractor() { super(new JdbcPetRowMapper(), new JdbcVisitRowMapper()); @@ -51,4 +51,4 @@ public class JdbcPetVisitExtractor extends protected void addChild(JdbcPet root, Visit child) { root.addVisit(child); } -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java index 79db917f9..0231275c1 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java @@ -60,25 +60,25 @@ public class JdbcVetRepositoryImpl implements VetRepository { List vets = new ArrayList<>(); // Retrieve the list of all vets. vets.addAll(this.jdbcTemplate.query( - "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name", - BeanPropertyRowMapper.newInstance(Vet.class))); + "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name", + BeanPropertyRowMapper.newInstance(Vet.class))); // Retrieve the list of all possible specialties. final List specialties = this.jdbcTemplate.query( - "SELECT id, name FROM specialties", - BeanPropertyRowMapper.newInstance(Specialty.class)); + "SELECT id, name FROM specialties", + BeanPropertyRowMapper.newInstance(Specialty.class)); // Build each vet's list of specialties. for (Vet vet : vets) { final List vetSpecialtiesIds = this.jdbcTemplate.query( - "SELECT specialty_id FROM vet_specialties WHERE vet_id=?", - new BeanPropertyRowMapper() { - @Override - public Integer mapRow(ResultSet rs, int row) throws SQLException { - return rs.getInt(1); - } - }, - vet.getId()); + "SELECT specialty_id FROM vet_specialties WHERE vet_id=?", + new BeanPropertyRowMapper() { + @Override + public Integer mapRow(ResultSet rs, int row) throws SQLException { + return rs.getInt(1); + } + }, + vet.getId()); for (int specialtyId : vetSpecialtiesIds) { Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId); vet.addSpecialty(specialty); diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java index a923b7652..330ca1a4c 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java @@ -50,8 +50,8 @@ public class JdbcVisitRepositoryImpl implements VisitRepository { this.jdbcTemplate = new JdbcTemplate(dataSource); this.insertVisit = new SimpleJdbcInsert(dataSource) - .withTableName("visits") - .usingGeneratedKeyColumns("id"); + .withTableName("visits") + .usingGeneratedKeyColumns("id"); } @@ -59,7 +59,7 @@ public class JdbcVisitRepositoryImpl implements VisitRepository { public void save(Visit visit) throws DataAccessException { if (visit.isNew()) { Number newKey = this.insertVisit.executeAndReturnKey( - createVisitParameterSource(visit)); + createVisitParameterSource(visit)); visit.setId(newKey.intValue()); } else { throw new UnsupportedOperationException("Visit update not supported"); @@ -72,17 +72,17 @@ public class JdbcVisitRepositoryImpl implements VisitRepository { */ private MapSqlParameterSource createVisitParameterSource(Visit visit) { return new MapSqlParameterSource() - .addValue("id", visit.getId()) - .addValue("visit_date", visit.getDate().toDate()) - .addValue("description", visit.getDescription()) - .addValue("pet_id", visit.getPet().getId()); + .addValue("id", visit.getId()) + .addValue("visit_date", visit.getDate().toDate()) + .addValue("description", visit.getDescription()) + .addValue("pet_id", visit.getPet().getId()); } @Override public List findByPetId(Integer petId) { return this.jdbcTemplate.query( - "SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=?", - new JdbcVisitRowMapper(), petId); + "SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=?", + new JdbcVisitRowMapper(), petId); } } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/package-info.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/package-info.java index edd0bf855..376da279f 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/package-info.java @@ -1,9 +1,6 @@ - /** - * * The classes in this package represent the JDBC implementation * of PetClinic's persistence layer. - * */ package org.springframework.samples.petclinic.repository.jdbc; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java index c7398df5b..3972dd349 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java @@ -43,7 +43,7 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository { /** - * Important: in the current version of this method, we load Owners with all their Pets and Visits while + * Important: in the current version of this method, we load Owners with all their Pets and Visits while * we do not need Visits at all and we only need one property from the Pet objects (the 'name' property). * There are some ways to improve it such as: * - creating a Ligtweight class (example here: https://community.jboss.org/wiki/LightweightClass) @@ -70,12 +70,11 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository { @Override public void save(Owner owner) { - if (owner.getId() == null) { - this.em.persist(owner); - } - else { - this.em.merge(owner); - } + if (owner.getId() == null) { + this.em.persist(owner); + } else { + this.em.merge(owner); + } } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImpl.java index 84d564da4..227140d96 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImpl.java @@ -53,12 +53,11 @@ public class JpaPetRepositoryImpl implements PetRepository { @Override public void save(Pet pet) { - if (pet.getId() == null) { - this.em.persist(pet); - } - else { - this.em.merge(pet); - } + if (pet.getId() == null) { + this.em.persist(pet); + } else { + this.em.merge(pet); + } } } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImpl.java index 3415def96..5d1d42a07 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImpl.java @@ -45,12 +45,11 @@ public class JpaVisitRepositoryImpl implements VisitRepository { @Override public void save(Visit visit) { - if (visit.getId() == null) { - this.em.persist(visit); - } - else { - this.em.merge(visit); - } + if (visit.getId() == null) { + this.em.persist(visit); + } else { + this.em.merge(visit); + } } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/package-info.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/package-info.java index 13c8552ed..087dc15b6 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/package-info.java @@ -1,9 +1,6 @@ - /** - * * The classes in this package represent the JPA implementation * of PetClinic's persistence layer. - * */ package org.springframework.samples.petclinic.repository.jpa; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepository.java index ca1f709f6..24c573eb7 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepository.java @@ -30,12 +30,12 @@ import org.springframework.samples.petclinic.repository.OwnerRepository; * @since 15.1.2013 */ public interface SpringDataOwnerRepository extends OwnerRepository, Repository { - - @Override - @Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%") - public Collection findByLastName(@Param("lastName") String lastName); - - @Override - @Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id") - public Owner findById(@Param("id") int id); + + @Override + @Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%") + public Collection findByLastName(@Param("lastName") String lastName); + + @Override + @Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id") + public Owner findById(@Param("id") int id); } diff --git a/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java b/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java index 494d6503e..fddf17dfa 100644 --- a/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java +++ b/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java @@ -26,8 +26,8 @@ import org.springframework.util.StopWatch; /** * Simple aspect that monitors call count and call invocation time. It uses JMX annotations and therefore can be * monitored using any JMX console such as the jConsole - * - * This is only useful if you use JPA or JDBC. Spring-data-jpa doesn't have any correctly annotated classes to join on + *

+ * This is only useful if you use JPA or JDBC. Spring-data-jpa doesn't have any correctly annotated classes to join on * * @author Rob Harrop * @author Juergen Hoeller @@ -44,17 +44,16 @@ public class CallMonitoringAspect { private long accumulatedCallTime = 0; - - @ManagedAttribute - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - @ManagedAttribute public boolean isEnabled() { return enabled; } + @ManagedAttribute + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + @ManagedOperation public void reset() { this.callCount = 0; @@ -68,10 +67,10 @@ public class CallMonitoringAspect { @ManagedAttribute public long getCallTime() { - if (this.callCount > 0) - return this.accumulatedCallTime / this.callCount; - else - return 0; + if (this.callCount > 0) + return this.accumulatedCallTime / this.callCount; + else + return 0; } diff --git a/src/main/java/org/springframework/samples/petclinic/util/EntityUtils.java b/src/main/java/org/springframework/samples/petclinic/util/EntityUtils.java index 41486a5a7..eee390694 100644 --- a/src/main/java/org/springframework/samples/petclinic/util/EntityUtils.java +++ b/src/main/java/org/springframework/samples/petclinic/util/EntityUtils.java @@ -39,11 +39,10 @@ public abstract class EntityUtils { * @param entityClass the entity class to look up * @param entityId the entity id to look up * @return the found entity - * @throws ObjectRetrievalFailureException - * if the entity was not found + * @throws ObjectRetrievalFailureException if the entity was not found */ public static T getById(Collection entities, Class entityClass, int entityId) - throws ObjectRetrievalFailureException { + throws ObjectRetrievalFailureException { for (T entity : entities) { if (entity.getId() == entityId && entityClass.isInstance(entity)) { return entity; diff --git a/src/main/java/org/springframework/samples/petclinic/web/CrashController.java b/src/main/java/org/springframework/samples/petclinic/web/CrashController.java index e413f3f3b..29c55c1c0 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/CrashController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/CrashController.java @@ -33,7 +33,7 @@ public class CrashController { @RequestMapping(value = "/oups", method = RequestMethod.GET) public String triggerException() { throw new RuntimeException("Expected: controller used to showcase what " + - "happens when an exception is thrown"); + "happens when an exception is thrown"); } diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java index 9f2ffb05c..4b54e0f9b 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java @@ -96,19 +96,17 @@ public class OwnerController { // no owners found result.rejectValue("lastName", "notFound", "not found"); return "owners/findOwners"; - } - else if (results.size() == 1) { - // 1 owner found - owner = results.iterator().next(); - return "redirect:/owners/" + owner.getId(); - } - else { + } else if (results.size() == 1) { + // 1 owner found + owner = results.iterator().next(); + return "redirect:/owners/" + owner.getId(); + } else { // multiple owners found model.put("selections", results); return "owners/ownersList"; } } - + @RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.GET) public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) { Owner owner = this.clinicService.findOwnerById(ownerId); diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java index 5784278b9..3aefb024e 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java @@ -41,14 +41,14 @@ public class PetValidator implements Validator { } else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) { errors.rejectValue("name", "duplicate", "already exists"); } - + // type validation if (pet.isNew() && pet.getType() == null) { errors.rejectValue("type", "required", "required"); } - + // birth date validation - if (pet.getBirthDate()==null) { + if (pet.getBirthDate() == null) { errors.rejectValue("birthDate", "required", "required"); } } diff --git a/src/main/java/org/springframework/samples/petclinic/web/VetController.java b/src/main/java/org/springframework/samples/petclinic/web/VetController.java index ebbb8d6e2..3121e60e8 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/VetController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/VetController.java @@ -41,19 +41,21 @@ public class VetController { this.clinicService = clinicService; } - @RequestMapping(value={"/vets.xml","/vets.html"}) + @RequestMapping(value = {"/vets.xml", "/vets.html"}) public String showVetList(Map model) { - // Here we are returning an object of type 'Vets' rather than a collection of Vet objects + // Here we are returning an object of type 'Vets' rather than a collection of Vet objects // so it is simpler for Object-Xml mapping Vets vets = new Vets(); vets.getVetList().addAll(this.clinicService.findVets()); model.put("vets", vets); return "vets/vetList"; } - + @RequestMapping("/vets.json") - public @ResponseBody Vets showResourcesVetList() { - // Here we are returning an object of type 'Vets' rather than a collection of Vet objects + public + @ResponseBody + Vets showResourcesVetList() { + // Here we are returning an object of type 'Vets' rather than a collection of Vet objects // so it is simpler for JSon/Object mapping Vets vets = new Vets(); vets.getVetList().addAll(this.clinicService.findVets()); diff --git a/src/main/java/org/springframework/samples/petclinic/web/VisitController.java b/src/main/java/org/springframework/samples/petclinic/web/VisitController.java index f3f6f3ffb..144eba2d9 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/VisitController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/VisitController.java @@ -53,13 +53,14 @@ public class VisitController { public void setAllowedFields(WebDataBinder dataBinder) { dataBinder.setDisallowedFields("id"); } - + /** - * Called before each and every @RequestMapping annotated method. - * 2 goals: - * - Make sure we always have fresh data - * - Since we do not use the session scope, make sure that Pet object always has an id - * (Even though id is not part of the form fields) + * Called before each and every @RequestMapping annotated method. + * 2 goals: + * - Make sure we always have fresh data + * - Since we do not use the session scope, make sure that Pet object always has an id + * (Even though id is not part of the form fields) + * * @param petId * @return Pet */ @@ -67,17 +68,17 @@ public class VisitController { public Visit loadPetWithVisit(@PathVariable("petId") int petId) { Pet pet = this.clinicService.findPetById(petId); Visit visit = new Visit(); - pet.addVisit(visit); + pet.addVisit(visit); return visit; } - // Spring MVC calls method loadPetWithVisit(...) before initNewVisitForm is called + // Spring MVC calls method loadPetWithVisit(...) before initNewVisitForm is called @RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET) public String initNewVisitForm(@PathVariable("petId") int petId, Map model) { return "pets/createOrUpdateVisitForm"; } - // Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called + // Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called @RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST) public String processNewVisitForm(@Valid Visit visit, BindingResult result) { if (result.hasErrors()) { diff --git a/src/main/java/org/springframework/samples/petclinic/web/package-info.java b/src/main/java/org/springframework/samples/petclinic/web/package-info.java index c909ccf7f..ca189f19a 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/package-info.java +++ b/src/main/java/org/springframework/samples/petclinic/web/package-info.java @@ -1,8 +1,5 @@ - /** - * * The classes in this package represent PetClinic's web presentation layer. - * */ package org.springframework.samples.petclinic.web; diff --git a/src/main/java/test.html b/src/main/java/test.html index 9a7a99675..8c5cb2cf3 100644 --- a/src/main/java/test.html +++ b/src/main/java/test.html @@ -1,39 +1,53 @@ - +

Organisation

Speakers

- - - - - - - - + + + + + + + +
- Sergiu Bodiu -

Sergiu Bodiu

-

Java Consultant at Bank of America

- Seasoned consultant experienced in large-scale e-commerce projects, passionate about providing innovative technology solutions to solve complex business problems, have extensive knowledge and experience delivering enterprise wide applications. He is skilled in software design, data modeling, stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, test and maintain software product components with strong focus on design elegance and software reuse. -
- Sergiu Bodiu -

Sergiu Bodiu

-

Java Consultant at Bank of America

- Seasoned consultant experienced in large-scale e-commerce projects, passionate about providing innovative technology solutions to solve complex business problems, have extensive knowledge and experience delivering enterprise wide applications. He is skilled in software design, data modeling, stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, test and maintain software product components with strong focus on design elegance and software reuse. -
+ Sergiu Bodiu + +

Sergiu Bodiu

+ +

Java Consultant at Bank of America

+ Seasoned consultant experienced in large-scale e-commerce projects, passionate about + providing innovative technology solutions to solve complex business problems, have extensive knowledge and + experience delivering enterprise wide applications. He is skilled in software design, data modeling, + stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, + test and maintain software product components with strong focus on design elegance and software reuse. +
+ Sergiu Bodiu + +

Sergiu Bodiu

+ +

Java Consultant at Bank of America

+ Seasoned consultant experienced in large-scale e-commerce projects, passionate about + providing innovative technology solutions to solve complex business problems, have extensive knowledge and + experience delivering enterprise wide applications. He is skilled in software design, data modeling, + stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement, + test and maintain software product components with strong focus on design elegance and software reuse. +
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 830ef37de..ba2b51463 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -16,9 +16,9 @@ - + - + diff --git a/src/main/resources/spring/business-config.xml b/src/main/resources/spring/business-config.xml index 99cf4c1d3..a029c45ab 100644 --- a/src/main/resources/spring/business-config.xml +++ b/src/main/resources/spring/business-config.xml @@ -2,36 +2,36 @@ - - + + base-package="org.springframework.samples.petclinic.service"/> - - - - - - + + + + + + @@ -93,4 +93,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/spring/datasource-config.xml b/src/main/resources/spring/datasource-config.xml index f74129963..aa705de14 100644 --- a/src/main/resources/spring/datasource-config.xml +++ b/src/main/resources/spring/datasource-config.xml @@ -2,11 +2,11 @@ - - + - \ No newline at end of file + diff --git a/src/main/resources/spring/mvc-core-config.xml b/src/main/resources/spring/mvc-core-config.xml index eab2062dc..641ea4408 100644 --- a/src/main/resources/spring/mvc-core-config.xml +++ b/src/main/resources/spring/mvc-core-config.xml @@ -2,11 +2,11 @@ - + base-package="org.springframework.samples.petclinic.web"/> @@ -31,11 +31,11 @@ - + - - + @@ -53,7 +53,7 @@ p:basename="messages/messages"/> diff --git a/src/main/resources/spring/mvc-view-config.xml b/src/main/resources/spring/mvc-view-config.xml index 309707cf1..9ba6723c5 100644 --- a/src/main/resources/spring/mvc-view-config.xml +++ b/src/main/resources/spring/mvc-view-config.xml @@ -2,9 +2,9 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/main/resources/spring/tools-config.xml b/src/main/resources/spring/tools-config.xml index 1be7e3b6c..61db5e57d 100644 --- a/src/main/resources/spring/tools-config.xml +++ b/src/main/resources/spring/tools-config.xml @@ -2,11 +2,11 @@ - <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp b/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp index 207a5b727..3cb66aa25 100644 --- a/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp +++ b/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp @@ -14,7 +14,7 @@
  • "> Veterinarians
  • " - title="trigger a RuntimeException to see how it is handled"> Error
  • diff --git a/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp b/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp index f1eea21e6..add28329f 100644 --- a/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp +++ b/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp @@ -18,13 +18,13 @@ PetClinic :: a Spring Framework demonstration - + - + - + diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index a3cc2ade9..0086220ce 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index 91d2ebabc..662ac7ffd 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 4ace4ba23..e4a970a2c 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -33,17 +33,17 @@ Telephone - - - + + + Edit Owner - + - Add New Pet + Add New Pet @@ -77,21 +77,21 @@ - - - - - - Edit Pet - - - - - - Add Visit + + + + + Edit Pet - + + + + + + Add Visit + + diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 5e8eaaaaa..68e4b0666 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -14,8 +14,8 @@

    Owners

    - - @@ -34,9 +34,9 @@ - + - +
    diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index a3d144135..387959b5d 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> @@ -13,7 +13,7 @@
    diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp index 501a0d48e..a5eb87fcd 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> @@ -16,7 +16,7 @@
    @@ -42,10 +42,10 @@ - - - - + + + +
    diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index 040679c28..d2794718d 100644 --- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp +++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -16,7 +16,8 @@

    Veterinarians

    - + @@ -27,7 +28,7 @@ none - +
    diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp index f33b84e55..4bd4f767f 100644 --- a/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp @@ -1,4 +1,4 @@ - + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index e699ca92d..ea965de25 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,33 +1,33 @@ - Spring PetClinic Spring PetClinic sample application - - + + spring.profiles.active jpa - - + + - - - + + + + + - encodingFilter - org.springframework.web.filter.CharacterEncodingFilter - - encoding - UTF-8 - - - forceEncoding - true - - - - - encodingFilter - /* - - + encodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + forceEncoding + true + + + + + encodingFilter + /* + + dandelionFilter @@ -100,19 +100,19 @@ /* - - + + datatables com.github.dandelion.datatables.core.web.filter.DatatablesFilter - - + + datatables /* - - + + - \ No newline at end of file + diff --git a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java index f8582b5d9..b836d0cc2 100644 --- a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java +++ b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java @@ -13,24 +13,22 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; /** - * * @author Michael Isvy - * Simple test to make sure that Bean Validation is working - * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) - * + * Simple test to make sure that Bean Validation is working + * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) */ public class ValidatorTests { - - private Validator createValidator() { - LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); - localValidatorFactoryBean.afterPropertiesSet(); - return localValidatorFactoryBean; - } - @Test + private Validator createValidator() { + LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); + localValidatorFactoryBean.afterPropertiesSet(); + return localValidatorFactoryBean; + } + + @Test public void shouldNotValidateWhenFirstNameEmpty() { - LocaleContextHolder.setLocale(Locale.ENGLISH); + LocaleContextHolder.setLocale(Locale.ENGLISH); Person person = new Person(); person.setFirstName(""); person.setLastName("smith"); @@ -39,9 +37,9 @@ public class ValidatorTests { Set> constraintViolations = validator.validate(person); assertThat(constraintViolations.size()).isEqualTo(1); - ConstraintViolation violation = constraintViolations.iterator().next(); + ConstraintViolation violation = constraintViolations.iterator().next(); assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName"); assertThat(violation.getMessage()).isEqualTo("may not be empty"); } - + } diff --git a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java index 473acdc6e..0dd87379b 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java @@ -69,8 +69,8 @@ public abstract class AbstractClinicServiceTests { Owner owner = this.clinicService.findOwnerById(1); assertThat(owner.getLastName()).startsWith("Franklin"); assertThat(owner.getPets().size()).isEqualTo(1); - assertThat(owner.getPets().get(0).getType()).isNotNull(); - assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat"); + assertThat(owner.getPets().get(0).getType()).isNotNull(); + assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat"); } @Test @@ -78,7 +78,7 @@ public abstract class AbstractClinicServiceTests { public void shouldInsertOwner() { Collection owners = this.clinicService.findOwnerByLastName("Schultz"); int found = owners.size(); - + Owner owner = new Owner(); owner.setFirstName("Sam"); owner.setLastName("Schultz"); @@ -94,11 +94,11 @@ public abstract class AbstractClinicServiceTests { @Test @Transactional - public void shouldUpdateOwner() { + public void shouldUpdateOwner() { Owner owner = this.clinicService.findOwnerById(1); String oldLastName = owner.getLastName(); String newLastName = oldLastName + "X"; - + owner.setLastName(newLastName); this.clinicService.saveOwner(owner); @@ -107,87 +107,87 @@ public abstract class AbstractClinicServiceTests { assertThat(owner.getLastName()).isEqualTo(newLastName); } - @Test - public void shouldFindPetWithCorrectId() { - Pet pet7 = this.clinicService.findPetById(7); - assertThat(pet7.getName()).startsWith("Samantha"); - assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean"); - - } + @Test + public void shouldFindPetWithCorrectId() { + Pet pet7 = this.clinicService.findPetById(7); + assertThat(pet7.getName()).startsWith("Samantha"); + assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean"); - @Test - public void shouldFindAllPetTypes() { - Collection petTypes = this.clinicService.findPetTypes(); - - PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1); - assertThat(petType1.getName()).isEqualTo("cat"); - PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4); - assertThat(petType4.getName()).isEqualTo("snake"); - } + } - @Test - @Transactional - public void shouldInsertPetIntoDatabaseAndGenerateId() { - Owner owner6 = this.clinicService.findOwnerById(6); - int found = owner6.getPets().size(); - - Pet pet = new Pet(); - pet.setName("bowser"); - Collection types = this.clinicService.findPetTypes(); - pet.setType(EntityUtils.getById(types, PetType.class, 2)); - pet.setBirthDate(new DateTime()); - owner6.addPet(pet); - assertThat(owner6.getPets().size()).isEqualTo(found + 1); - - this.clinicService.savePet(pet); - this.clinicService.saveOwner(owner6); - - owner6 = this.clinicService.findOwnerById(6); - assertThat(owner6.getPets().size()).isEqualTo(found + 1); - // checks that id has been generated - assertThat(pet.getId()).isNotNull(); - } + @Test + public void shouldFindAllPetTypes() { + Collection petTypes = this.clinicService.findPetTypes(); - @Test - @Transactional - public void shouldUpdatePetName() throws Exception { - Pet pet7 = this.clinicService.findPetById(7); - String oldName = pet7.getName(); - - String newName = oldName + "X"; - pet7.setName(newName); - this.clinicService.savePet(pet7); + PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1); + assertThat(petType1.getName()).isEqualTo("cat"); + PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4); + assertThat(petType4.getName()).isEqualTo("snake"); + } - pet7 = this.clinicService.findPetById(7); - assertThat(pet7.getName()).isEqualTo(newName); - } + @Test + @Transactional + public void shouldInsertPetIntoDatabaseAndGenerateId() { + Owner owner6 = this.clinicService.findOwnerById(6); + int found = owner6.getPets().size(); - @Test - public void shouldFindVets() { - Collection vets = this.clinicService.findVets(); - - Vet vet = EntityUtils.getById(vets, Vet.class, 3); - assertThat(vet.getLastName()).isEqualTo("Douglas"); - assertThat(vet.getNrOfSpecialties()).isEqualTo(2); - assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry"); - assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery"); - } + Pet pet = new Pet(); + pet.setName("bowser"); + Collection types = this.clinicService.findPetTypes(); + pet.setType(EntityUtils.getById(types, PetType.class, 2)); + pet.setBirthDate(new DateTime()); + owner6.addPet(pet); + assertThat(owner6.getPets().size()).isEqualTo(found + 1); - @Test - @Transactional - public void shouldAddNewVisitForPet() { - Pet pet7 = this.clinicService.findPetById(7); - int found = pet7.getVisits().size(); - Visit visit = new Visit(); - pet7.addVisit(visit); - visit.setDescription("test"); - this.clinicService.saveVisit(visit); - this.clinicService.savePet(pet7); + this.clinicService.savePet(pet); + this.clinicService.saveOwner(owner6); - pet7 = this.clinicService.findPetById(7); - assertThat(pet7.getVisits().size()).isEqualTo(found + 1); - assertThat(visit.getId()).isNotNull(); - } + owner6 = this.clinicService.findOwnerById(6); + assertThat(owner6.getPets().size()).isEqualTo(found + 1); + // checks that id has been generated + assertThat(pet.getId()).isNotNull(); + } + + @Test + @Transactional + public void shouldUpdatePetName() throws Exception { + Pet pet7 = this.clinicService.findPetById(7); + String oldName = pet7.getName(); + + String newName = oldName + "X"; + pet7.setName(newName); + this.clinicService.savePet(pet7); + + pet7 = this.clinicService.findPetById(7); + assertThat(pet7.getName()).isEqualTo(newName); + } + + @Test + public void shouldFindVets() { + Collection vets = this.clinicService.findVets(); + + Vet vet = EntityUtils.getById(vets, Vet.class, 3); + assertThat(vet.getLastName()).isEqualTo("Douglas"); + assertThat(vet.getNrOfSpecialties()).isEqualTo(2); + assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry"); + assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery"); + } + + @Test + @Transactional + public void shouldAddNewVisitForPet() { + Pet pet7 = this.clinicService.findPetById(7); + int found = pet7.getVisits().size(); + Visit visit = new Visit(); + pet7.addVisit(visit); + visit.setDescription("test"); + this.clinicService.saveVisit(visit); + this.clinicService.savePet(pet7); + + pet7 = this.clinicService.findPetById(7); + assertThat(pet7.getVisits().size()).isEqualTo(found + 1); + assertThat(visit.getId()).isNotNull(); + } } diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java index 49e57ea40..74c5df7cf 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java @@ -21,11 +21,11 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** - *

    Integration test using the jdbc profile. - * @see AbstractClinicServiceTests AbstractClinicServiceTests for more details.

    + *

    Integration test using the jdbc profile. * * @author Thomas Risberg * @author Michael Isvy + * @see AbstractClinicServiceTests AbstractClinicServiceTests for more details.

    */ @ContextConfiguration(locations = {"classpath:spring/business-config.xml"}) @RunWith(SpringJUnit4ClassRunner.class) diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java index e024f21fd..dba2b195a 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java @@ -1,4 +1,3 @@ - package org.springframework.samples.petclinic.service; import org.junit.runner.RunWith; @@ -7,12 +6,12 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** - *

    Integration test using the jpa profile. - * @see AbstractClinicServiceTests AbstractClinicServiceTests for more details.

    + *

    Integration test using the jpa profile. * * @author Rod Johnson * @author Sam Brannen * @author Michael Isvy + * @see AbstractClinicServiceTests AbstractClinicServiceTests for more details.

    */ @ContextConfiguration(locations = {"classpath:spring/business-config.xml"}) @@ -20,4 +19,4 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ActiveProfiles("jpa") public class ClinicServiceJpaTests extends AbstractClinicServiceTests { -} \ No newline at end of file +} diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java index e01dda551..31b62289f 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceSpringDataJpaTests.java @@ -1,4 +1,3 @@ - package org.springframework.samples.petclinic.service; import org.junit.runner.RunWith; @@ -7,9 +6,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** - *

    Integration test using the 'Spring Data' profile. - * @see AbstractClinicServiceTests AbstractClinicServiceTests for more details.

    + *

    Integration test using the 'Spring Data' profile. + * * @author Michael Isvy + * @see AbstractClinicServiceTests AbstractClinicServiceTests for more details.

    */ @ContextConfiguration(locations = {"classpath:spring/business-config.xml"}) @@ -17,4 +17,4 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ActiveProfiles("spring-data-jpa") public class ClinicServiceSpringDataJpaTests extends AbstractClinicServiceTests { -} \ No newline at end of file +} diff --git a/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java index 61e6d3287..28b9348a1 100644 --- a/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/web/VetControllerTests.java @@ -40,9 +40,9 @@ public class VetControllerTests { @Test public void testGetExistingUser() throws Exception { - ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); - actions.andExpect(content().contentType("application/json;charset=UTF-8")) - .andExpect(jsonPath("$.vetList[0].id").value(1)); + ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + actions.andExpect(content().contentType("application/json;charset=UTF-8")) + .andExpect(jsonPath("$.vetList[0].id").value(1)); } } From 2270e2466b58006f94d6ed9bee3c18e3d4bc408c Mon Sep 17 00:00:00 2001 From: Tomas Repel Date: Fri, 16 Oct 2015 15:04:17 +0200 Subject: [PATCH 099/109] Removal of redundant comments --- .../samples/petclinic/model/Vets.java | 1 - .../petclinic/repository/OwnerRepository.java | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/model/Vets.java b/src/main/java/org/springframework/samples/petclinic/model/Vets.java index aaf96b685..a6f05c606 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Vets.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Vets.java @@ -1,4 +1,3 @@ -/* /* * Copyright 2002-2013 the original author or authors. * diff --git a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java index a273a1f7f..a0869d1e3 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java @@ -1,18 +1,3 @@ -/* - * Copyright 2002-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /* * Copyright 2002-2013 the original author or authors. * From 81fac33fb56d7642d50084e373a13e59b5b64688 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 16 Oct 2015 18:20:57 +0200 Subject: [PATCH 100/109] #96 change EditorConfig in order to impact other files than Java and XML (i.e.. jsp and html pages) --- .editorconfig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index de9af4689..8d67bc7a5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,12 @@ # top-most EditorConfig file root = true -[*.{java,xml}] +[*] charset = utf-8 -indent_style = space -indent_size = 4 +end_of_line = lf insert_final_newline = true +indent_style = space + +[*.{java,xml}] +indent_size = 4 trim_trailing_whitespace = true From 63d8f1213ccd9028754e91b85c2358175fd0f7a4 Mon Sep 17 00:00:00 2001 From: Tomas Repel Date: Mon, 19 Oct 2015 10:53:10 +0200 Subject: [PATCH 101/109] Update of Dandelion to 1.1.1 --- pom.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d4c16ce5b..fdd16f409 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,8 @@ 2.3.0 1.10.3 2.0.3-1 - 1.0.1 + 1.1.1 + 1.1.0 2.7 @@ -260,13 +261,18 @@ com.github.dandelion - datatables-jsp + dandelion-jsp ${dandelion.version} + + com.github.dandelion + datatables-jsp + ${dandelion.datatables.version} + com.github.dandelion datatables-export-itext - ${dandelion.version} + ${dandelion.datatables.version} From 5e11b4bbccd0d120b02dabb64b79b05347936b35 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 20 Oct 2015 18:59:10 +0200 Subject: [PATCH 102/109] JMeter script from Julien Dubois --- src/test/jmeter/petclinic_test_plan.jmx | 431 ++++++++++++++++++++++++ 1 file changed, 431 insertions(+) create mode 100644 src/test/jmeter/petclinic_test_plan.jmx diff --git a/src/test/jmeter/petclinic_test_plan.jmx b/src/test/jmeter/petclinic_test_plan.jmx new file mode 100644 index 000000000..5eca11de4 --- /dev/null +++ b/src/test/jmeter/petclinic_test_plan.jmx @@ -0,0 +1,431 @@ + + + + + + false + false + + + + PETCLINIC_HOST + localhost + = + + + PETCLINIC_PORT + 8080 + = + + + CONTEXT_WEB + + = + + + + + + + + continue + + false + 10 + + 500 + 10 + 1361531541000 + 1361531541000 + false + + + true + Original : 500 - 10 - 10 + + + + 300 + + + + + + + ${PETCLINIC_HOST} + ${PETCLINIC_PORT} + + + + + + 4 + + + + + true + + + + 1 + 10 + 1 + count + + false + + + + 1 + 13 + 1 + petCount + + false + + + + + + + + + + + + + ${CONTEXT_WEB}/ + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/resources/css/petclinic.css + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/resources/js/jquery.js + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/webjars/jquery/2.0.3/jquery.js + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/vets.html + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/find.html + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners.html?lastName= + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}.html + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/edit.html + GET + true + false + true + false + false + + + + + true + + + + false + _method=put&firstName=Test&lastName=${count}&address=1234+Test+St.&city=TestCity&telephone=612345678 + = + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/edit.html + POST + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new + GET + true + false + true + false + false + + + + + true + + + + false + date=2013%2F02%2F22&description=visit + = + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new + POST + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}.html + GET + true + false + true + false + false + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + true + true + + + + + + + + + From 6a94d7e60aabb1914cebfa84d00bd258862d6db2 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 21 Oct 2015 08:25:07 +0200 Subject: [PATCH 103/109] Remove uncessary _method=put parameter and enable the "POST new visit" HTTP request --- src/test/jmeter/petclinic_test_plan.jmx | 26 +++---------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/test/jmeter/petclinic_test_plan.jmx b/src/test/jmeter/petclinic_test_plan.jmx index 5eca11de4..cd36ba08c 100644 --- a/src/test/jmeter/petclinic_test_plan.jmx +++ b/src/test/jmeter/petclinic_test_plan.jmx @@ -125,26 +125,6 @@ - - - - - - - - - - - ${CONTEXT_WEB}/resources/js/jquery.js - GET - true - false - true - false - false - - - @@ -271,7 +251,7 @@ false - _method=put&firstName=Test&lastName=${count}&address=1234+Test+St.&city=TestCity&telephone=612345678 + firstName=Test&lastName=${count}&address=1234+Test+St.&city=TestCity&telephone=612345678 = @@ -312,7 +292,7 @@ - + true @@ -359,7 +339,7 @@ - + false saveConfig From 3bcf84543ec586173731942a83178eed561f7d3a Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Thu, 22 Oct 2015 08:36:29 +0200 Subject: [PATCH 104/109] #77 move Session scope attributes to the request scope instead --- .../petclinic/web/OwnerController.java | 9 +-- .../samples/petclinic/web/PetController.java | 57 +++++++++++-------- .../samples/petclinic/web/PetValidator.java | 2 - src/main/webapp/WEB-INF/jsp/exception.jsp | 1 + .../jsp/owners/createOrUpdateOwnerForm.jsp | 1 + .../webapp/WEB-INF/jsp/owners/findOwners.jsp | 1 + .../WEB-INF/jsp/owners/ownerDetails.jsp | 1 + .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 1 + .../jsp/pets/createOrUpdatePetForm.jsp | 2 + .../jsp/pets/createOrUpdateVisitForm.jsp | 1 + src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 1 + src/main/webapp/WEB-INF/jsp/welcome.jsp | 1 + 12 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java index 4b54e0f9b..c2d45bb8c 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java @@ -31,8 +31,6 @@ import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.SessionAttributes; -import org.springframework.web.bind.support.SessionStatus; import org.springframework.web.servlet.ModelAndView; /** @@ -42,7 +40,6 @@ import org.springframework.web.servlet.ModelAndView; * @author Michael Isvy */ @Controller -@SessionAttributes(types = Owner.class) public class OwnerController { private final ClinicService clinicService; @@ -66,12 +63,11 @@ public class OwnerController { } @RequestMapping(value = "/owners/new", method = RequestMethod.POST) - public String processCreationForm(@Valid Owner owner, BindingResult result, SessionStatus status) { + public String processCreationForm(@Valid Owner owner, BindingResult result) { if (result.hasErrors()) { return "owners/createOrUpdateOwnerForm"; } else { this.clinicService.saveOwner(owner); - status.setComplete(); return "redirect:/owners/" + owner.getId(); } } @@ -115,12 +111,11 @@ public class OwnerController { } @RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.POST) - public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, SessionStatus status) { + public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result) { if (result.hasErrors()) { return "owners/createOrUpdateOwnerForm"; } else { this.clinicService.saveOwner(owner); - status.setComplete(); return "redirect:/owners/{ownerId}"; } } diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetController.java b/src/main/java/org/springframework/samples/petclinic/web/PetController.java index 9fdae6855..39c7f1cb3 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetController.java @@ -15,26 +15,20 @@ */ package org.springframework.samples.petclinic.web; -import java.util.Collection; -import java.util.Map; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.samples.petclinic.model.Owner; import org.springframework.samples.petclinic.model.Pet; import org.springframework.samples.petclinic.model.PetType; import org.springframework.samples.petclinic.service.ClinicService; import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.SessionAttributes; -import org.springframework.web.bind.support.SessionStatus; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.Collection; /** * @author Juergen Hoeller @@ -42,12 +36,11 @@ import javax.validation.Valid; * @author Arjen Poutsma */ @Controller -@SessionAttributes("pet") +@RequestMapping("/owners/{ownerId}") public class PetController { private final ClinicService clinicService; - @Autowired public PetController(ClinicService clinicService) { this.clinicService = clinicService; @@ -58,46 +51,60 @@ public class PetController { return this.clinicService.findPetTypes(); } - @InitBinder - public void initBinder(WebDataBinder dataBinder) { + @ModelAttribute("owner") + public Owner findOwner(@PathVariable("ownerId") int ownerId) { + Owner owner = this.clinicService.findOwnerById(ownerId); + return owner; + } + + @InitBinder("owner") + public void initOwnerBinder(WebDataBinder dataBinder) { dataBinder.setDisallowedFields("id"); + } + + @InitBinder("pet") + public void initPetBinder(WebDataBinder dataBinder) { dataBinder.setValidator(new PetValidator()); } - @RequestMapping(value = "/owners/{ownerId}/pets/new", method = RequestMethod.GET) - public String initCreationForm(@PathVariable("ownerId") int ownerId, Map model) { - Owner owner = this.clinicService.findOwnerById(ownerId); + @RequestMapping(value = "/pets/new", method = RequestMethod.GET) + public String initCreationForm(Owner owner, ModelMap model) { Pet pet = new Pet(); owner.addPet(pet); model.put("pet", pet); return "pets/createOrUpdatePetForm"; } - @RequestMapping(value = "/owners/{ownerId}/pets/new", method = RequestMethod.POST) - public String processCreationForm(@Valid Pet pet, BindingResult result, SessionStatus status) { + @RequestMapping(value = "/pets/new", method = RequestMethod.POST) + public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model) { + if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null){ + result.rejectValue("name", "duplicate", "already exists"); + } if (result.hasErrors()) { + model.put("pet", pet); return "pets/createOrUpdatePetForm"; } else { + owner.addPet(pet); this.clinicService.savePet(pet); - status.setComplete(); return "redirect:/owners/{ownerId}"; } } - @RequestMapping(value = "/owners/*/pets/{petId}/edit", method = RequestMethod.GET) - public String initUpdateForm(@PathVariable("petId") int petId, Map model) { + @RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.GET) + public String initUpdateForm(@PathVariable("petId") int petId, ModelMap model) { Pet pet = this.clinicService.findPetById(petId); model.put("pet", pet); return "pets/createOrUpdatePetForm"; } - @RequestMapping(value = "/owners/{ownerId}/pets/{petId}/edit", method = RequestMethod.POST) - public String processUpdateForm(@Valid Pet pet, BindingResult result, SessionStatus status) { + @RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.POST) + public String processUpdateForm(@Valid Pet pet, Owner owner, BindingResult result, ModelMap model) { if (result.hasErrors()) { + model.put("pet", pet); return "pets/createOrUpdatePetForm"; } else { + owner.addPet(pet); this.clinicService.savePet(pet); - status.setComplete(); return "redirect:/owners/{ownerId}"; } } diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java index 3aefb024e..d889d1af6 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetValidator.java @@ -38,8 +38,6 @@ public class PetValidator implements Validator { // name validation if (!StringUtils.hasLength(name)) { errors.rejectValue("name", "required", "required"); - } else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) { - errors.rejectValue("name", "duplicate", "already exists"); } // type validation diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp index 3d7ef0b01..3c7a5f404 100644 --- a/src/main/webapp/WEB-INF/jsp/exception.jsp +++ b/src/main/webapp/WEB-INF/jsp/exception.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index 0086220ce..30329e107 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index 662ac7ffd..f6b1930eb 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index e4a970a2c..8e7e10bbd 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 68e4b0666..2e88f0fb8 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index 387959b5d..985984aba 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> @@ -26,6 +27,7 @@ +
    diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp index a5eb87fcd..a90e757f8 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index d2794718d..1c57ea93c 100644 --- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp +++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp index 4bd4f767f..a1cf5fcae 100644 --- a/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp @@ -1,5 +1,6 @@ +<%@ page session="false" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> From dd552f497084f240eec49e4373de5f6a2af64b0a Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Mon, 26 Oct 2015 18:35:40 +0100 Subject: [PATCH 105/109] Fix #108 owner update --- .../springframework/samples/petclinic/web/OwnerController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java index c2d45bb8c..1a50a6906 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java @@ -111,10 +111,11 @@ public class OwnerController { } @RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.POST) - public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result) { + public String processUpdateOwnerForm(@Valid Owner owner, @PathVariable("ownerId") int ownerId, BindingResult result) { if (result.hasErrors()) { return "owners/createOrUpdateOwnerForm"; } else { + owner.setId(ownerId); this.clinicService.saveOwner(owner); return "redirect:/owners/{ownerId}"; } From 4aa89ae4e2b75e37aa8869b48ab1908e61af74e0 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 28 Oct 2015 08:30:44 +0100 Subject: [PATCH 106/109] Fix #110 owner and pet validators failed --- .../springframework/samples/petclinic/web/OwnerController.java | 2 +- .../springframework/samples/petclinic/web/PetController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java index 1a50a6906..0ff2858d5 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerController.java @@ -111,7 +111,7 @@ public class OwnerController { } @RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.POST) - public String processUpdateOwnerForm(@Valid Owner owner, @PathVariable("ownerId") int ownerId, BindingResult result) { + public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, @PathVariable("ownerId") int ownerId) { if (result.hasErrors()) { return "owners/createOrUpdateOwnerForm"; } else { diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetController.java b/src/main/java/org/springframework/samples/petclinic/web/PetController.java index 39c7f1cb3..a94499759 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetController.java @@ -98,7 +98,7 @@ public class PetController { } @RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.POST) - public String processUpdateForm(@Valid Pet pet, Owner owner, BindingResult result, ModelMap model) { + public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) { if (result.hasErrors()) { model.put("pet", pet); return "pets/createOrUpdatePetForm"; From 92de6557e10b610f3ea6579a6be67c53c4f766bc Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 28 Oct 2015 08:57:42 +0100 Subject: [PATCH 107/109] Fix #111 For pet's birthday we are now using jodatime LocalDate instead of DateTime --- .../org/springframework/samples/petclinic/model/Pet.java | 9 +++++---- .../petclinic/repository/jdbc/JdbcPetRowMapper.java | 3 ++- .../petclinic/service/AbstractClinicServiceTests.java | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/model/Pet.java b/src/main/java/org/springframework/samples/petclinic/model/Pet.java index 09eeb769e..970cdcb76 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Pet.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Pet.java @@ -32,6 +32,7 @@ import javax.persistence.Table; import org.hibernate.annotations.Type; import org.joda.time.DateTime; +import org.joda.time.LocalDate; import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.PropertyComparator; import org.springframework.format.annotation.DateTimeFormat; @@ -48,9 +49,9 @@ import org.springframework.format.annotation.DateTimeFormat; public class Pet extends NamedEntity { @Column(name = "birth_date") - @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") + @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate") @DateTimeFormat(pattern = "yyyy/MM/dd") - private DateTime birthDate; + private LocalDate birthDate; @ManyToOne @JoinColumn(name = "type_id") @@ -63,11 +64,11 @@ public class Pet extends NamedEntity { @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER) private Set visits; - public DateTime getBirthDate() { + public LocalDate getBirthDate() { return this.birthDate; } - public void setBirthDate(DateTime birthDate) { + public void setBirthDate(LocalDate birthDate) { this.birthDate = birthDate; } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java index ad00a7163..6420df163 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java @@ -20,6 +20,7 @@ import java.sql.SQLException; import java.util.Date; import org.joda.time.DateTime; +import org.joda.time.LocalDate; import org.springframework.jdbc.core.RowMapper; /** @@ -34,7 +35,7 @@ class JdbcPetRowMapper implements RowMapper { pet.setId(rs.getInt("pets.id")); pet.setName(rs.getString("name")); Date birthDate = rs.getDate("birth_date"); - pet.setBirthDate(new DateTime(birthDate)); + pet.setBirthDate(new LocalDate(birthDate)); pet.setTypeId(rs.getInt("type_id")); pet.setOwnerId(rs.getInt("owner_id")); return pet; diff --git a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java index 0dd87379b..469c24b47 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java @@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Collection; import org.joda.time.DateTime; +import org.joda.time.LocalDate; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.samples.petclinic.model.Owner; @@ -135,7 +136,7 @@ public abstract class AbstractClinicServiceTests { pet.setName("bowser"); Collection types = this.clinicService.findPetTypes(); pet.setType(EntityUtils.getById(types, PetType.class, 2)); - pet.setBirthDate(new DateTime()); + pet.setBirthDate(new LocalDate()); owner6.addPet(pet); assertThat(owner6.getPets().size()).isEqualTo(found + 1); From 19d7767318a0ec41db45e876175ac89a701843c9 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 28 Oct 2015 18:39:02 +0100 Subject: [PATCH 108/109] #98 Add a contributing section --- readme.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/readme.md b/readme.md index 8c84871da..229758c3a 100644 --- a/readme.md +++ b/readme.md @@ -204,5 +204,12 @@ Here is a list of them:
    +# Contributing + +The [issue tracker](https://github.com/spring-projects/spring-petclinic/issues) is the preferred channel for bug reports, features requests and submitting pull requests. + +For pull requests, editor preferences are available in the [editor config](https://github.com/spring-projects/spring-petclinic/blob/master/.editorconfig) for easy use in common text editors. Read more and download plugins at . + + From e00dfb3fe05cef910495b38d5a24221188e2e1a6 Mon Sep 17 00:00:00 2001 From: Tomas Repel Date: Mon, 2 Nov 2015 10:51:04 +0100 Subject: [PATCH 109/109] Using jodatime LocalDate instead of DateTime for visits --- .../samples/petclinic/model/Visit.java | 12 ++++++------ .../repository/jdbc/JdbcVisitRowMapper.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/model/Visit.java b/src/main/java/org/springframework/samples/petclinic/model/Visit.java index ea03bde74..023a8dcef 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Visit.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Visit.java @@ -23,7 +23,7 @@ import javax.persistence.Table; import org.hibernate.annotations.Type; import org.hibernate.validator.constraints.NotEmpty; -import org.joda.time.DateTime; +import org.joda.time.LocalDate; import org.springframework.format.annotation.DateTimeFormat; /** @@ -39,9 +39,9 @@ public class Visit extends BaseEntity { * Holds value of property date. */ @Column(name = "visit_date") - @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") + @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate") @DateTimeFormat(pattern = "yyyy/MM/dd") - private DateTime date; + private LocalDate date; /** * Holds value of property description. @@ -62,7 +62,7 @@ public class Visit extends BaseEntity { * Creates a new instance of Visit for the current date */ public Visit() { - this.date = new DateTime(); + this.date = new LocalDate(); } @@ -71,7 +71,7 @@ public class Visit extends BaseEntity { * * @return Value of property date. */ - public DateTime getDate() { + public LocalDate getDate() { return this.date; } @@ -80,7 +80,7 @@ public class Visit extends BaseEntity { * * @param date New value of property date. */ - public void setDate(DateTime date) { + public void setDate(LocalDate date) { this.date = date; } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java index 94069042b..edc4527a3 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java @@ -16,7 +16,7 @@ package org.springframework.samples.petclinic.repository.jdbc; -import org.joda.time.DateTime; +import org.joda.time.LocalDate; import org.springframework.jdbc.core.RowMapper; import org.springframework.samples.petclinic.model.Visit; @@ -35,7 +35,7 @@ class JdbcVisitRowMapper implements RowMapper { Visit visit = new Visit(); visit.setId(rs.getInt("visit_id")); Date visitDate = rs.getDate("visit_date"); - visit.setDate(new DateTime(visitDate)); + visit.setDate(new LocalDate(visitDate)); visit.setDescription(rs.getString("description")); return visit; }