From a6e81a51a0739ba2d22afbc10e52eeaa708abe0a Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 17 Jun 2016 18:38:24 +0200 Subject: [PATCH] #164 Spring Boot version of Petclinic ready to deploy to an external web container (ie Tomcat) --- pom.xml | 181 ++++++------------ .../petclinic/PetClinicApplication.java | 57 ++++++ .../config/CustomViewsConfiguration.java | 42 ++++ .../petclinic/config/DandelionConfig.java | 60 ++++++ .../samples/petclinic/model/Owner.java | 4 +- .../samples/petclinic/model/Pet.java | 4 + .../petclinic/repository/OwnerRepository.java | 33 ++-- .../petclinic/repository/PetRepository.java | 29 ++- .../petclinic/repository/VetRepository.java | 3 +- .../petclinic/repository/VisitRepository.java | 3 +- .../jdbc/JdbcOwnerRepositoryImpl.java | 158 --------------- .../petclinic/repository/jdbc/JdbcPet.java | 48 ----- .../jdbc/JdbcPetRepositoryImpl.java | 133 ------------- .../repository/jdbc/JdbcPetRowMapper.java | 43 ----- .../jdbc/JdbcPetVisitExtractor.java | 54 ------ .../jdbc/JdbcVetRepositoryImpl.java | 89 --------- .../jdbc/JdbcVisitRepositoryImpl.java | 105 ---------- .../repository/jdbc/JdbcVisitRowMapper.java | 42 ---- .../repository/jdbc/package-info.java | 6 - .../jpa/JpaOwnerRepositoryImpl.java | 81 -------- .../repository/jpa/JpaPetRepositoryImpl.java | 63 ------ .../repository/jpa/JpaVetRepositoryImpl.java | 51 ----- .../jpa/JpaVisitRepositoryImpl.java | 64 ------- .../repository/jpa/package-info.java | 6 - .../SpringDataOwnerRepository.java | 41 ---- .../SpringDataPetRepository.java | 38 ---- .../SpringDataVisitRepository.java | 29 --- .../petclinic/util/CallMonitoringAspect.java | 97 ---------- .../CustomErrorController.java} | 30 +-- .../petclinic/web/PetTypeFormatter.java | 2 + .../petclinic/web/WelcomeController.java | 14 ++ src/main/java/overview.html | 7 - src/main/java/test.html | 53 ----- src/main/resources/application.properties | 23 +++ src/main/resources/banner.txt | 15 ++ src/main/resources/{cache => }/ehcache.xml | 0 src/main/resources/{cache => }/ehcache.xsd | 0 src/main/resources/logback.xml | 22 --- src/main/resources/spring/business-config.xml | 96 ---------- .../resources/spring/data-access.properties | 34 ---- .../resources/spring/datasource-config.xml | 43 ----- src/main/resources/spring/mvc-core-config.xml | 65 ------- src/main/resources/spring/mvc-view-config.xml | 40 ---- src/main/resources/spring/tools-config.xml | 49 ----- src/main/webapp/WEB-INF/jsp/exception.jsp | 4 +- .../jsp/owners/createOrUpdateOwnerForm.jsp | 4 +- .../webapp/WEB-INF/jsp/owners/findOwners.jsp | 4 +- .../WEB-INF/jsp/owners/ownerDetails.jsp | 4 +- .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 4 +- .../jsp/pets/createOrUpdatePetForm.jsp | 4 +- .../jsp/pets/createOrUpdateVisitForm.jsp | 4 +- src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 4 +- src/main/webapp/WEB-INF/jsp/welcome.jsp | 4 +- .../WEB-INF/no-spring-config-files-there.txt | 4 - .../fragments/footer.jsp => tags/footer.tag} | 0 .../htmlHeader.jsp => tags/htmlHeader.tag} | 0 src/main/webapp/WEB-INF/tags/menu.tag | 2 +- src/main/webapp/WEB-INF/web.xml | 118 ------------ .../service/ClinicServiceJdbcTests.java | 36 ---- .../service/ClinicServiceJpaTests.java | 22 --- .../ClinicServiceSpringDataJpaTests.java | 5 +- .../petclinic/web/CrashControllerTests.java | 21 +- .../petclinic/web/OwnerControllerTests.java | 12 +- .../petclinic/web/PetControllerTests.java | 12 +- .../petclinic/web/VetControllerTests.java | 13 +- .../petclinic/web/VisitControllerTests.java | 11 +- 66 files changed, 385 insertions(+), 1964 deletions(-) create mode 100644 src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java create mode 100644 src/main/java/org/springframework/samples/petclinic/config/CustomViewsConfiguration.java create mode 100644 src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetVisitExtractor.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jdbc/package-info.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImpl.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/jpa/package-info.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepository.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepository.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepository.java delete mode 100644 src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java rename src/main/java/org/springframework/samples/petclinic/{repository/springdatajpa/SpringDataVetRepository.java => web/CustomErrorController.java} (51%) create mode 100644 src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java delete mode 100644 src/main/java/overview.html delete mode 100644 src/main/java/test.html create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/banner.txt rename src/main/resources/{cache => }/ehcache.xml (100%) rename src/main/resources/{cache => }/ehcache.xsd (100%) delete mode 100644 src/main/resources/logback.xml delete mode 100644 src/main/resources/spring/business-config.xml delete mode 100644 src/main/resources/spring/data-access.properties delete mode 100644 src/main/resources/spring/datasource-config.xml delete mode 100644 src/main/resources/spring/mvc-core-config.xml delete mode 100644 src/main/resources/spring/mvc-view-config.xml delete mode 100644 src/main/resources/spring/tools-config.xml delete mode 100644 src/main/webapp/WEB-INF/no-spring-config-files-there.txt rename src/main/webapp/WEB-INF/{jsp/fragments/footer.jsp => tags/footer.tag} (100%) rename src/main/webapp/WEB-INF/{jsp/fragments/htmlHeader.jsp => tags/htmlHeader.tag} (100%) delete mode 100644 src/main/webapp/WEB-INF/web.xml delete mode 100644 src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJdbcTests.java delete mode 100644 src/test/java/org/springframework/samples/petclinic/service/ClinicServiceJpaTests.java diff --git a/pom.xml b/pom.xml index 13040a701..277927bfa 100644 --- a/pom.xml +++ b/pom.xml @@ -3,9 +3,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 org.springframework.samples - spring-petclinic - 4.2.5-SNAPSHOT - + springboot-petclinic + 1.3.5-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.3.5.RELEASE + petclinic war @@ -16,16 +20,12 @@ UTF-8 UTF-8 - - 2.0.3.RELEASE - 1.1.0.RELEASE - - 7.0.59 2.2.0 + 1.3 1.3 @@ -43,89 +43,29 @@ - - - - - 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.jstl - javax.servlet.jsp.jstl-api - - - org.apache.taglibs - taglibs-standard-jstlel - - - - com.jayway.jsonpath - json-path - test - - + org.springframework.boot - spring-boot-starter + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-cache org.springframework.boot spring-boot-starter-data-jpa - - org.springframework.data - spring-data-jdbc-core - ${spring-data-jdbc.version} - - - org.springframework - * - - - - - - - org.springframework - spring-jdbc + org.springframework.boot + spring-boot-starter-test + test - org.springframework - spring-webmvc + org.springframework.boot + spring-boot-starter-web - org.springframework spring-context-support @@ -135,6 +75,33 @@ spring-oxm + + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.apache.tomcat.embed + tomcat-embed-jasper + provided + + + javax.servlet + jstl + + + + + + com.jayway.jsonpath + json-path + test + + + org.aspectj aspectjrt @@ -181,6 +148,11 @@ joda-time-jsptags ${jodatime-jsptags.version} + + org.jadira.usertype + usertype.core + ${jadira-usertype-core.version} + @@ -196,20 +168,7 @@ ${mysql-driver.version} - - - org.hibernate - hibernate-entitymanager - - - org.hibernate - hibernate-validator - - - - org.hibernate - hibernate-ehcache - + net.sf.ehcache ehcache @@ -222,32 +181,12 @@ - - org.springframework - spring-test - test - - - junit - junit - test - org.assertj assertj-core ${assertj.version} test - - org.mockito - mockito-core - test - - - org.hamcrest - hamcrest-all - test - @@ -276,16 +215,14 @@ install - - - - ${project.basedir}/src/test/java - - - ${project.basedir}/src/test/resources - - + + org.springframework.boot + spring-boot-maven-plugin + + boot + + org.apache.maven.plugins maven-compiler-plugin diff --git a/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java b/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java new file mode 100644 index 000000000..c1639946b --- /dev/null +++ b/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java @@ -0,0 +1,57 @@ +/* + * Copyright 2002-2014 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. + */ + +package org.springframework.samples.petclinic; + +import com.github.dandelion.core.web.DandelionFilter; +import com.github.dandelion.core.web.DandelionServlet; +import net.sf.ehcache.config.CacheConfiguration; +import net.sf.ehcache.config.PersistenceConfiguration; +import net.sf.ehcache.config.PersistenceConfiguration.Strategy; +import net.sf.ehcache.store.MemoryStoreEvictionPolicy; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.context.embedded.FilterRegistrationBean; +import org.springframework.boot.context.embedded.ServletRegistrationBean; +import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.ehcache.EhCacheCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; +import org.springframework.samples.petclinic.model.Vets; +import org.springframework.web.servlet.view.xml.MarshallingView; + +/** + * PetClinic Spring Boot Application. + * + */ +@Configuration +@EnableAutoConfiguration +@EnableCaching +@ComponentScan +public class PetClinicApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(PetClinicApplication.class); + } + +} diff --git a/src/main/java/org/springframework/samples/petclinic/config/CustomViewsConfiguration.java b/src/main/java/org/springframework/samples/petclinic/config/CustomViewsConfiguration.java new file mode 100644 index 000000000..9bfdd1cdc --- /dev/null +++ b/src/main/java/org/springframework/samples/petclinic/config/CustomViewsConfiguration.java @@ -0,0 +1,42 @@ +/* + * Copyright 2002-2016 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. + */ + +package org.springframework.samples.petclinic.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; +import org.springframework.samples.petclinic.model.Vets; +import org.springframework.web.servlet.view.BeanNameViewResolver; +import org.springframework.web.servlet.view.xml.MarshallingView; + +/** + * + * {@link BeanNameViewResolver} is used to resolve the Atom and Xml views. So, the + * following beans names must match the name of the JSP you want to override and the + * file extension will indicate which bean to use for resolving. + * + */ +@Configuration +public class CustomViewsConfiguration { + + @Bean(name = "vets/vetList.xml") + public MarshallingView vetsXmlView() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setClassesToBeBound(Vets.class); + return new MarshallingView(marshaller); + } +} diff --git a/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java b/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java new file mode 100644 index 000000000..ec6e01786 --- /dev/null +++ b/src/main/java/org/springframework/samples/petclinic/config/DandelionConfig.java @@ -0,0 +1,60 @@ +/* + * Copyright 2002-2016 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. + */ + +package org.springframework.samples.petclinic.config; + +import com.github.dandelion.core.web.DandelionFilter; +import com.github.dandelion.core.web.DandelionServlet; +import com.github.dandelion.datatables.core.web.filter.DatatablesFilter; +import org.springframework.boot.context.embedded.FilterRegistrationBean; +import org.springframework.boot.context.embedded.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Description; + +/** + * Java configuration for the Dandelion datatables component. + * + * @author Antoine Rey + */ +@Configuration +public class DandelionConfig { + + @Bean + @Description("Dandelion filter definition and mapping") + public FilterRegistrationBean filterRegistrationBean() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); + filterRegistrationBean.setFilter(new DandelionFilter()); + return filterRegistrationBean; + } + + @Bean + @Description("Dandelion-Datatables filter, used for basic export") + public FilterRegistrationBean datatablesRegistrationBean() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); + filterRegistrationBean.setFilter(new DatatablesFilter()); + return filterRegistrationBean; + } + + @Bean + public ServletRegistrationBean servletRegistrationBean() { + ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); + servletRegistrationBean.setServlet(new DandelionServlet()); + servletRegistrationBean.addUrlMappings("/dandelion-assets/*"); + servletRegistrationBean.setName("dandelionServlet"); + return servletRegistrationBean; + } +} 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 d0158d907..9a09bd775 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Owner.java @@ -103,7 +103,9 @@ public class Owner extends Person { } public void addPet(Pet pet) { - getPetsInternal().add(pet); + if (pet.isNew()) { + getPetsInternal().add(pet); + } pet.setOwner(this); } 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 970cdcb76..3dec7a310 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/Pet.java +++ b/src/main/java/org/springframework/samples/petclinic/model/Pet.java @@ -110,4 +110,8 @@ public class Pet extends NamedEntity { visit.setPet(this); } + + + + } 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 a0869d1e3..841d0bcd8 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepository.java @@ -18,6 +18,9 @@ package org.springframework.samples.petclinic.repository; import java.util.Collection; import org.springframework.dao.DataAccessException; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.model.Owner; @@ -30,35 +33,31 @@ import org.springframework.samples.petclinic.model.Owner; * @author Sam Brannen * @author Michael Isvy */ -public interface OwnerRepository { +public interface OwnerRepository extends Repository { /** - * Retrieve Owners from the data store by last name, returning all owners whose last name starts - * with the given name. - * + * Retrieve {@link Owner}s from the data store by last name, returning all owners + * whose last name starts with the given name. * @param lastName Value to search for - * @return a Collection of matching Owners (or an empty Collection if none + * @return a Collection of matching {@link Owner}s (or an empty Collection if none * found) */ - Collection findByLastName(String lastName) throws DataAccessException; + @Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%") + Collection findByLastName(@Param("lastName") String lastName); /** - * Retrieve an Owner from the data store by id. - * + * Retrieve an {@link Owner} from the data store by id. * @param id the id to search for - * @return the Owner if found - * @throws org.springframework.dao.DataRetrievalFailureException if not found + * @return the {@link Owner} if found */ - Owner findById(int id) throws DataAccessException; - + @Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id") + Owner findById(@Param("id") int id); /** - * Save an Owner to the data store, either inserting or updating it. - * - * @param owner the Owner to save - * @see BaseEntity#isNew + * Save an {@link Owner} to the data store, either inserting or updating it. + * @param owner the {@link Owner} to save */ - void save(Owner owner) throws DataAccessException; + void save(Owner owner); } 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 1770e8555..58e73d7f6 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/PetRepository.java @@ -18,6 +18,8 @@ package org.springframework.samples.petclinic.repository; import java.util.List; import org.springframework.dao.DataAccessException; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.model.Pet; import org.springframework.samples.petclinic.model.PetType; @@ -31,30 +33,27 @@ import org.springframework.samples.petclinic.model.PetType; * @author Sam Brannen * @author Michael Isvy */ -public interface PetRepository { +public interface PetRepository extends Repository { /** - * Retrieve all PetTypes from the data store. - * - * @return a Collection of PetTypes + * Retrieve all {@link PetType}s from the data store. + * @return a Collection of {@link PetType}s. */ - List findPetTypes() throws DataAccessException; + @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name") + List findPetTypes(); /** - * Retrieve a Pet from the data store by id. - * + * Retrieve a {@link Pet} from the data store by id. * @param id the id to search for - * @return the Pet if found - * @throws org.springframework.dao.DataRetrievalFailureException if not found + * @return the {@link Pet} if found */ - Pet findById(int id) throws DataAccessException; + Pet findById(int id); /** - * Save a Pet to the data store, either inserting or updating it. - * - * @param pet the Pet to save - * @see BaseEntity#isNew + * Save a {@link Pet} to the data store, either inserting or updating it. + * @param pet the {@link Pet} to save */ - void save(Pet pet) throws DataAccessException; + void save(Pet pet); } + diff --git a/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java index 923c3c23d..aabdfd65d 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/VetRepository.java @@ -18,6 +18,7 @@ package org.springframework.samples.petclinic.repository; import java.util.Collection; import org.springframework.dao.DataAccessException; +import org.springframework.data.repository.Repository; import org.springframework.samples.petclinic.model.Vet; /** @@ -29,7 +30,7 @@ import org.springframework.samples.petclinic.model.Vet; * @author Sam Brannen * @author Michael Isvy */ -public interface VetRepository { +public interface VetRepository extends Repository { /** * Retrieve all Vets from the data store. diff --git a/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java index 96b7a208c..e734f3275 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java @@ -18,6 +18,7 @@ package org.springframework.samples.petclinic.repository; import java.util.List; import org.springframework.dao.DataAccessException; +import org.springframework.data.repository.Repository; import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.model.Visit; @@ -30,7 +31,7 @@ import org.springframework.samples.petclinic.model.Visit; * @author Sam Brannen * @author Michael Isvy */ -public interface VisitRepository { +public interface VisitRepository extends Repository { /** * Save a Visit to the data store, either inserting or updating it. 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 deleted file mode 100644 index 45de1aee0..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcOwnerRepositoryImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.jdbc.core.BeanPropertyRowMapper; -import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import org.springframework.jdbc.core.simple.SimpleJdbcInsert; -import org.springframework.orm.ObjectRetrievalFailureException; -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.model.Visit; -import org.springframework.samples.petclinic.repository.OwnerRepository; -import org.springframework.samples.petclinic.util.EntityUtils; -import org.springframework.stereotype.Repository; - -/** - * A simple JDBC-based implementation of the {@link OwnerRepository} interface. - * - * @author Ken Krebs - * @author Juergen Hoeller - * @author Rob Harrop - * @author Sam Brannen - * @author Thomas Risberg - * @author Mark Fisher - */ -@Repository -public class JdbcOwnerRepositoryImpl implements OwnerRepository { - - private NamedParameterJdbcTemplate namedParameterJdbcTemplate; - - private SimpleJdbcInsert insertOwner; - - @Autowired - public JdbcOwnerRepositoryImpl(DataSource dataSource, NamedParameterJdbcTemplate namedParameterJdbcTemplate) { - - this.insertOwner = new SimpleJdbcInsert(dataSource) - .withTableName("owners") - .usingGeneratedKeyColumns("id"); - - this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); - - } - - - /** - * Loads {@link Owner Owners} from the data store by last name, returning all owners whose last name starts with - * the given name; also loads the {@link Pet Pets} and {@link Visit Visits} for the corresponding owners, if not - * already loaded. - */ - @Override - public Collection findByLastName(String lastName) throws DataAccessException { - 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) - ); - loadOwnersPetsAndVisits(owners); - return owners; - } - - /** - * Loads the {@link Owner} with the supplied id; also loads the {@link Pet Pets} and {@link Visit Visits} - * for the corresponding owner, if not already loaded. - */ - @Override - public Owner findById(int id) throws DataAccessException { - Owner owner; - try { - 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) - ); - } catch (EmptyResultDataAccessException ex) { - throw new ObjectRetrievalFailureException(Owner.class, id); - } - loadPetsAndVisits(owner); - return owner; - } - - public void loadPetsAndVisits(final Owner owner) { - 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() - ); - Collection petTypes = getPetTypes(); - for (JdbcPet pet : pets) { - pet.setType(EntityUtils.getById(petTypes, PetType.class, pet.getTypeId())); - owner.addPet(pet); - } - } - - @Override - public void save(Owner owner) throws DataAccessException { - BeanPropertySqlParameterSource parameterSource = new BeanPropertySqlParameterSource(owner); - if (owner.isNew()) { - Number newKey = this.insertOwner.executeAndReturnKey(parameterSource); - 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); - } - } - - public Collection getPetTypes() throws DataAccessException { - return this.namedParameterJdbcTemplate.query( - "SELECT id, name FROM types ORDER BY name", new HashMap(), - BeanPropertyRowMapper.newInstance(PetType.class)); - } - - /** - * Loads the {@link Pet} and {@link Visit} data for the supplied {@link List} of {@link Owner Owners}. - * - * @param owners the list of owners for whom the pet and visit data should be loaded - * @see #loadPetsAndVisits(Owner) - */ - private void loadOwnersPetsAndVisits(List owners) { - for (Owner owner : owners) { - loadPetsAndVisits(owner); - } - } - - -} 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 deleted file mode 100644 index 4c266b931..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPet.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ -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 implementation of the - * PetRepository. - * - * @author Juergen Hoeller - */ -class JdbcPet extends Pet { - - private int typeId; - - private int ownerId; - - public int getTypeId() { - return this.typeId; - } - - 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 deleted file mode 100644 index 885c2bc2f..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.jdbc.core.BeanPropertyRowMapper; -import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import org.springframework.jdbc.core.simple.SimpleJdbcInsert; -import org.springframework.orm.ObjectRetrievalFailureException; -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.model.Visit; -import org.springframework.samples.petclinic.repository.OwnerRepository; -import org.springframework.samples.petclinic.repository.PetRepository; -import org.springframework.samples.petclinic.repository.VisitRepository; -import org.springframework.samples.petclinic.util.EntityUtils; -import org.springframework.stereotype.Repository; - -/** - * @author Ken Krebs - * @author Juergen Hoeller - * @author Rob Harrop - * @author Sam Brannen - * @author Thomas Risberg - * @author Mark Fisher - */ -@Repository -public class JdbcPetRepositoryImpl implements PetRepository { - - private NamedParameterJdbcTemplate namedParameterJdbcTemplate; - - private SimpleJdbcInsert insertPet; - - private OwnerRepository ownerRepository; - - private VisitRepository visitRepository; - - - @Autowired - public JdbcPetRepositoryImpl(DataSource dataSource, OwnerRepository ownerRepository, VisitRepository visitRepository) { - this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); - - this.insertPet = new SimpleJdbcInsert(dataSource) - .withTableName("pets") - .usingGeneratedKeyColumns("id"); - - this.ownerRepository = ownerRepository; - this.visitRepository = visitRepository; - } - - @Override - 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)); - } - - @Override - public Pet findById(int id) throws DataAccessException { - JdbcPet pet; - try { - 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()); - } catch (EmptyResultDataAccessException ex) { - throw new ObjectRetrievalFailureException(Pet.class, id); - } - Owner owner = this.ownerRepository.findById(pet.getOwnerId()); - owner.addPet(pet); - pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId())); - - List visits = this.visitRepository.findByPetId(pet.getId()); - for (Visit visit : visits) { - pet.addVisit(visit); - } - return pet; - } - - @Override - public void save(Pet pet) throws DataAccessException { - if (pet.isNew()) { - Number newKey = this.insertPet.executeAndReturnKey( - 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)); - } - } - - /** - * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Pet} instance. - */ - 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()); - } - -} 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 deleted file mode 100644 index 6420df163..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Date; - -import org.joda.time.DateTime; -import org.joda.time.LocalDate; -import org.springframework.jdbc.core.RowMapper; - -/** - * {@link RowMapper} implementation mapping data from a {@link ResultSet} to the corresponding properties - * of the {@link JdbcPet} class. - */ -class JdbcPetRowMapper implements RowMapper { - - @Override - public JdbcPet mapRow(ResultSet rs, int rownum) throws SQLException { - JdbcPet pet = new JdbcPet(); - pet.setId(rs.getInt("pets.id")); - pet.setName(rs.getString("name")); - Date birthDate = rs.getDate("birth_date"); - pet.setBirthDate(new LocalDate(birthDate)); - pet.setTypeId(rs.getInt("type_id")); - pet.setOwnerId(rs.getInt("owner_id")); - return pet; - } -} 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 deleted file mode 100644 index 6a4ba62c3..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetVisitExtractor.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2002-2015 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - -import org.springframework.data.jdbc.core.OneToManyResultSetExtractor; -import org.springframework.jdbc.core.ResultSetExtractor; -import org.springframework.samples.petclinic.model.Visit; - -import java.sql.ResultSet; -import java.sql.SQLException; - -/** - * {@link ResultSetExtractor} implementation by using the - * {@link OneToManyResultSetExtractor} of Spring Data Core JDBC Extensions. - */ -public class JdbcPetVisitExtractor extends - OneToManyResultSetExtractor { - - public JdbcPetVisitExtractor() { - super(new JdbcPetRowMapper(), new JdbcVisitRowMapper()); - } - - @Override - protected Integer mapPrimaryKey(ResultSet rs) throws SQLException { - return rs.getInt("pets.id"); - } - - @Override - protected Integer mapForeignKey(ResultSet rs) throws SQLException { - if (rs.getObject("visits.pet_id") == null) { - return null; - } else { - return rs.getInt("visits.pet_id"); - } - } - - @Override - protected void addChild(JdbcPet root, Visit child) { - root.addVisit(child); - } -} 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 deleted file mode 100644 index 0231275c1..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVetRepositoryImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.BeanPropertyRowMapper; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.samples.petclinic.model.Specialty; -import org.springframework.samples.petclinic.model.Vet; -import org.springframework.samples.petclinic.repository.VetRepository; -import org.springframework.samples.petclinic.util.EntityUtils; -import org.springframework.stereotype.Repository; - -/** - * A simple JDBC-based implementation of the {@link VetRepository} interface. - * - * @author Ken Krebs - * @author Juergen Hoeller - * @author Rob Harrop - * @author Sam Brannen - * @author Thomas Risberg - * @author Mark Fisher - * @author Michael Isvy - */ -@Repository -public class JdbcVetRepositoryImpl implements VetRepository { - - private JdbcTemplate jdbcTemplate; - - @Autowired - public JdbcVetRepositoryImpl(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } - - /** - * Refresh the cache of Vets that the ClinicService is holding. - */ - @Override - public Collection findAll() throws DataAccessException { - 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))); - - // Retrieve the list of all possible specialties. - final List specialties = this.jdbcTemplate.query( - "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()); - for (int specialtyId : vetSpecialtiesIds) { - Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId); - vet.addSpecialty(specialty); - } - } - return vets; - } -} 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 deleted file mode 100644 index ecae18d99..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import org.springframework.jdbc.core.simple.SimpleJdbcInsert; -import org.springframework.samples.petclinic.model.Visit; -import org.springframework.samples.petclinic.repository.VisitRepository; -import org.springframework.stereotype.Repository; - -import javax.sql.DataSource; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * A simple JDBC-based implementation of the {@link VisitRepository} interface. - * - * @author Ken Krebs - * @author Juergen Hoeller - * @author Rob Harrop - * @author Sam Brannen - * @author Thomas Risberg - * @author Mark Fisher - * @author Michael Isvy - */ -@Repository -public class JdbcVisitRepositoryImpl implements VisitRepository { - - private NamedParameterJdbcTemplate jdbcTemplate; - - private SimpleJdbcInsert insertVisit; - - @Autowired - public JdbcVisitRepositoryImpl(DataSource dataSource) { - this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); - - this.insertVisit = new SimpleJdbcInsert(dataSource) - .withTableName("visits") - .usingGeneratedKeyColumns("id"); - } - - - @Override - public void save(Visit visit) throws DataAccessException { - if (visit.isNew()) { - Number newKey = this.insertVisit.executeAndReturnKey( - createVisitParameterSource(visit)); - visit.setId(newKey.intValue()); - } else { - throw new UnsupportedOperationException("Visit update not supported"); - } - } - - - /** - * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit} instance. - */ - 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()); - } - - @Override - public List findByPetId(Integer petId) { - Map params = new HashMap<>(); - params.put("id", petId); - JdbcPet pet = this.jdbcTemplate.queryForObject( - "SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id", - params, - new JdbcPetRowMapper()); - - List visits = this.jdbcTemplate.query( - "SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=:id", - params, new JdbcVisitRowMapper()); - - for (Visit visit: visits) { - visit.setPet(pet); - } - - return visits; - } - -} 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 deleted file mode 100644 index edc4527a3..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2002-2015 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. - */ -package org.springframework.samples.petclinic.repository.jdbc; - - -import org.joda.time.LocalDate; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.samples.petclinic.model.Visit; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Date; - -/** - * {@link RowMapper} implementation mapping data from a {@link ResultSet} to the corresponding properties - * of the {@link Visit} class. - */ -class JdbcVisitRowMapper implements RowMapper { - - @Override - public Visit mapRow(ResultSet rs, int row) throws SQLException { - Visit visit = new Visit(); - visit.setId(rs.getInt("visit_id")); - Date visitDate = rs.getDate("visit_date"); - visit.setDate(new LocalDate(visitDate)); - visit.setDescription(rs.getString("description")); - return visit; - } -} 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 deleted file mode 100644 index 376da279f..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 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 deleted file mode 100644 index 3972dd349..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jpa; - -import java.util.Collection; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; - -import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter; -import org.springframework.samples.petclinic.model.Owner; -import org.springframework.samples.petclinic.repository.OwnerRepository; -import org.springframework.stereotype.Repository; - -/** - * JPA implementation of the {@link OwnerRepository} interface. - * - * @author Mike Keith - * @author Rod Johnson - * @author Sam Brannen - * @author Michael Isvy - * @since 22.4.2006 - */ -@Repository -public class JpaOwnerRepositoryImpl implements OwnerRepository { - - @PersistenceContext - private EntityManager em; - - - /** - * 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) - * - Turning on lazy-loading and using {@link OpenSessionInViewFilter} - */ - @SuppressWarnings("unchecked") - public Collection findByLastName(String lastName) { - // using 'join fetch' because a single query should load both owners and pets - // using 'left join fetch' because it might happen that an owner does not have pets yet - Query query = this.em.createQuery("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName"); - query.setParameter("lastName", lastName + "%"); - return query.getResultList(); - } - - @Override - public Owner findById(int id) { - // using 'join fetch' because a single query should load both owners and pets - // using 'left join fetch' because it might happen that an owner does not have pets yet - Query query = this.em.createQuery("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id"); - query.setParameter("id", id); - return (Owner) query.getSingleResult(); - } - - - @Override - public void save(Owner 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 deleted file mode 100644 index 227140d96..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetRepositoryImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jpa; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import org.springframework.samples.petclinic.model.Pet; -import org.springframework.samples.petclinic.model.PetType; -import org.springframework.samples.petclinic.repository.PetRepository; -import org.springframework.stereotype.Repository; - -/** - * JPA implementation of the {@link PetRepository} interface. - * - * @author Mike Keith - * @author Rod Johnson - * @author Sam Brannen - * @author Michael Isvy - * @since 22.4.2006 - */ -@Repository -public class JpaPetRepositoryImpl implements PetRepository { - - @PersistenceContext - private EntityManager em; - - @Override - @SuppressWarnings("unchecked") - public List findPetTypes() { - return this.em.createQuery("SELECT ptype FROM PetType ptype ORDER BY ptype.name").getResultList(); - } - - @Override - public Pet findById(int id) { - return this.em.find(Pet.class, id); - } - - @Override - public void save(Pet 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/JpaVetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java deleted file mode 100644 index e4c222b65..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jpa; - -import java.util.Collection; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import org.springframework.cache.annotation.Cacheable; -import org.springframework.samples.petclinic.model.Vet; -import org.springframework.samples.petclinic.repository.VetRepository; -import org.springframework.stereotype.Repository; - -/** - * JPA implementation of the {@link VetRepository} interface. - * - * @author Mike Keith - * @author Rod Johnson - * @author Sam Brannen - * @author Michael Isvy - * @since 22.4.2006 - */ -@Repository -public class JpaVetRepositoryImpl implements VetRepository { - - @PersistenceContext - private EntityManager em; - - - @Override - @Cacheable(value = "vets") - @SuppressWarnings("unchecked") - public Collection findAll() { - return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList(); - } - -} 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 deleted file mode 100644 index 16a9b3536..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVisitRepositoryImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.jpa; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; - -import org.springframework.samples.petclinic.model.Visit; -import org.springframework.samples.petclinic.repository.VisitRepository; -import org.springframework.stereotype.Repository; - -/** - * JPA implementation of the ClinicService interface using EntityManager. - *

- *

The mappings are defined in "orm.xml" located in the META-INF directory. - * - * @author Mike Keith - * @author Rod Johnson - * @author Sam Brannen - * @author Michael Isvy - * @since 22.4.2006 - */ -@Repository -public class JpaVisitRepositoryImpl implements VisitRepository { - - @PersistenceContext - private EntityManager em; - - - @Override - public void save(Visit visit) { - if (visit.getId() == null) { - this.em.persist(visit); - } else { - this.em.merge(visit); - } - } - - - @Override - @SuppressWarnings("unchecked") - public List findByPetId(Integer petId) { - Query query = this.em.createQuery("SELECT v FROM Visit v where v.pet.id= :id"); - query.setParameter("id", petId); - return query.getResultList(); - } - -} 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 deleted file mode 100644 index 087dc15b6..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 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 deleted file mode 100644 index 24c573eb7..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepository.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.springdatajpa; - -import java.util.Collection; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.Repository; -import org.springframework.data.repository.query.Param; -import org.springframework.samples.petclinic.model.Owner; -import org.springframework.samples.petclinic.repository.OwnerRepository; - -/** - * Spring Data JPA specialization of the {@link OwnerRepository} interface - * - * @author Michael Isvy - * @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); -} diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepository.java deleted file mode 100644 index 56a413147..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.springdatajpa; - -import java.util.List; - -import org.springframework.dao.DataAccessException; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.Repository; -import org.springframework.samples.petclinic.model.Pet; -import org.springframework.samples.petclinic.model.PetType; -import org.springframework.samples.petclinic.repository.PetRepository; - -/** - * Spring Data JPA specialization of the {@link PetRepository} interface - * - * @author Michael Isvy - * @since 15.1.2013 - */ -public interface SpringDataPetRepository extends PetRepository, Repository { - - @Override - @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name") - List findPetTypes() throws DataAccessException; -} diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepository.java deleted file mode 100644 index 84740224b..000000000 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepository.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.repository.springdatajpa; - -import org.springframework.data.repository.Repository; -import org.springframework.samples.petclinic.model.Visit; -import org.springframework.samples.petclinic.repository.VisitRepository; - -/** - * Spring Data JPA specialization of the {@link VisitRepository} interface - * - * @author Michael Isvy - * @since 15.1.2013 - */ -public interface SpringDataVisitRepository extends VisitRepository, Repository { -} diff --git a/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java b/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java deleted file mode 100644 index fddf17dfa..000000000 --- a/src/main/java/org/springframework/samples/petclinic/util/CallMonitoringAspect.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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. - */ -package org.springframework.samples.petclinic.util; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.jmx.export.annotation.ManagedAttribute; -import org.springframework.jmx.export.annotation.ManagedOperation; -import org.springframework.jmx.export.annotation.ManagedResource; -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 - * - * @author Rob Harrop - * @author Juergen Hoeller - * @author Michael Isvy - * @since 2.5 - */ -@ManagedResource("petclinic:type=CallMonitor") -@Aspect -public class CallMonitoringAspect { - - private boolean enabled = true; - - private int callCount = 0; - - private long accumulatedCallTime = 0; - - @ManagedAttribute - public boolean isEnabled() { - return enabled; - } - - @ManagedAttribute - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - @ManagedOperation - public void reset() { - this.callCount = 0; - this.accumulatedCallTime = 0; - } - - @ManagedAttribute - public int getCallCount() { - return callCount; - } - - @ManagedAttribute - public long getCallTime() { - if (this.callCount > 0) - return this.accumulatedCallTime / this.callCount; - else - return 0; - } - - - @Around("within(@org.springframework.stereotype.Repository *)") - public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { - if (this.enabled) { - StopWatch sw = new StopWatch(joinPoint.toShortString()); - - sw.start("invoke"); - try { - return joinPoint.proceed(); - } finally { - sw.stop(); - synchronized (this) { - this.callCount++; - this.accumulatedCallTime += sw.getTotalTimeMillis(); - } - } - } else { - return joinPoint.proceed(); - } - } - -} diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepository.java b/src/main/java/org/springframework/samples/petclinic/web/CustomErrorController.java similarity index 51% rename from src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepository.java rename to src/main/java/org/springframework/samples/petclinic/web/CustomErrorController.java index b8211b707..965697c65 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepository.java +++ b/src/main/java/org/springframework/samples/petclinic/web/CustomErrorController.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -13,17 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.repository.springdatajpa; -import org.springframework.data.repository.Repository; -import org.springframework.samples.petclinic.model.Vet; -import org.springframework.samples.petclinic.repository.VetRepository; +package org.springframework.samples.petclinic.web; -/** - * Spring Data JPA specialization of the {@link VetRepository} interface - * - * @author Michael Isvy - * @since 15.1.2013 - */ -public interface SpringDataVetRepository extends VetRepository, Repository { +import org.springframework.boot.autoconfigure.web.ErrorController; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class CustomErrorController implements ErrorController { + + @RequestMapping(value = "/error") + public String error() { + return "exception"; + } + + @Override + public String getErrorPath() { + return "/error"; + } } diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetTypeFormatter.java b/src/main/java/org/springframework/samples/petclinic/web/PetTypeFormatter.java index 3d47d2201..71a060ca5 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetTypeFormatter.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetTypeFormatter.java @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.Formatter; import org.springframework.samples.petclinic.model.PetType; import org.springframework.samples.petclinic.service.ClinicService; +import org.springframework.stereotype.Component; /** * Instructs Spring MVC on how to parse and print elements of type 'PetType'. Starting from Spring 3.0, Formatters have @@ -37,6 +38,7 @@ import org.springframework.samples.petclinic.service.ClinicService; * @author Juergen Hoeller * @author Michael Isvy */ +@Component public class PetTypeFormatter implements Formatter { private final ClinicService clinicService; diff --git a/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java b/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java new file mode 100644 index 000000000..efa9c3236 --- /dev/null +++ b/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java @@ -0,0 +1,14 @@ +package org.springframework.samples.petclinic.web; + + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class WelcomeController { + + @RequestMapping("/") + public String welcome() { + return "welcome"; + } +} diff --git a/src/main/java/overview.html b/src/main/java/overview.html deleted file mode 100644 index df4f4d6b7..000000000 --- a/src/main/java/overview.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

- The Spring Data Binding framework, an internal library used by Spring Web Flow. -

- - \ No newline at end of file diff --git a/src/main/java/test.html b/src/main/java/test.html deleted file mode 100644 index 8c5cb2cf3..000000000 --- a/src/main/java/test.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - -

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. -
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 000000000..688ae2044 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,23 @@ +# Web +spring.mvc.view.prefix: /WEB-INF/jsp/ +spring.mvc.view.suffix: .jsp + + +# JPA +spring.jpa.hibernate.ddl-auto: none +#spring.jpa.database: HSQL +#spring.jpa.show-sql: true +#spring.datasource.driverClassName=org.hsqldb.jdbcDriver +spring.datasource.schema: classpath*:db/hsqldb/initDB.sql +spring.datasource.data: classpath*:db/hsqldb/populateDB.sql +#spring.datasource.username: sa +#spring.datasource.password: + +# Internationalization +spring.messages.basename: messages/messages + +# Actuator / Management +management.contextPath: /manage + +# Logging +logging.level.org.springframework=INFO diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 000000000..6225d1208 --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,15 @@ + + + |\ _,,,--,,_ + /,`.-'`' ._ \-;;,_ + _______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______ + | | '---''(_/._)-'(_\_) | | | | | | | | | + | _ | ___|_ _| | | | | |_| | | | __ _ _ + | |_| | |___ | | | | | | | | | | \ \ \ \ + | ___| ___| | | | _| |___| | _ | | _| \ \ \ \ + | | | |___ | | | |_| | | | | | | |_ ) ) ) ) + |___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / / + ==================================================================/_/_/_/ + +:: Built with Spring Boot :: ${spring-boot.version} + diff --git a/src/main/resources/cache/ehcache.xml b/src/main/resources/ehcache.xml similarity index 100% rename from src/main/resources/cache/ehcache.xml rename to src/main/resources/ehcache.xml diff --git a/src/main/resources/cache/ehcache.xsd b/src/main/resources/ehcache.xsd similarity index 100% rename from src/main/resources/cache/ehcache.xsd rename to src/main/resources/ehcache.xsd diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index 54bfd5f2d..000000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - true - - - - - %-5level %logger{0} - %msg%n - - - - - - - - - - diff --git a/src/main/resources/spring/business-config.xml b/src/main/resources/spring/business-config.xml deleted file mode 100644 index a029c45ab..000000000 --- a/src/main/resources/spring/business-config.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/spring/data-access.properties b/src/main/resources/spring/data-access.properties deleted file mode 100644 index 567f726a4..000000000 --- a/src/main/resources/spring/data-access.properties +++ /dev/null @@ -1,34 +0,0 @@ -# Properties file with JDBC and JPA settings. -# -# Applied by from -# 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 - -jdbc.driverClassName=org.hsqldb.jdbcDriver -jdbc.url=jdbc:hsqldb:mem:petclinic -jdbc.username=sa -jdbc.password= - -# Property that determines which database to use with an AbstractJpaVendorAdapter -jpa.database=HSQL - - -#------------------------------------------------------------------------------- -# MySQL Settings - -#jdbc.driverClassName=com.mysql.jdbc.Driver -#jdbc.url=jdbc:mysql://localhost:3306/petclinic?useUnicode=true&characterEncoding=UTF-8 -#jdbc.username=root -#jdbc.password=petclinic - -# Property that determines which database to use with an AbstractJpaVendorAdapter -#jpa.database=MYSQL diff --git a/src/main/resources/spring/datasource-config.xml b/src/main/resources/spring/datasource-config.xml deleted file mode 100644 index aa705de14..000000000 --- a/src/main/resources/spring/datasource-config.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/spring/mvc-core-config.xml b/src/main/resources/spring/mvc-core-config.xml deleted file mode 100644 index 6e254423f..000000000 --- a/src/main/resources/spring/mvc-core-config.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/spring/mvc-view-config.xml b/src/main/resources/spring/mvc-view-config.xml deleted file mode 100644 index 9ba6723c5..000000000 --- a/src/main/resources/spring/mvc-view-config.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/spring/tools-config.xml b/src/main/resources/spring/tools-config.xml deleted file mode 100644 index 61db5e57d..000000000 --- a/src/main/resources/spring/tools-config.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp index a4fde6ca3..21932524d 100644 --- a/src/main/webapp/WEB-INF/jsp/exception.jsp +++ b/src/main/webapp/WEB-INF/jsp/exception.jsp @@ -6,7 +6,7 @@ <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> - + @@ -28,7 +28,7 @@ - + diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index 77826de8a..d5cf881f6 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp @@ -11,7 +11,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index e9f9b9061..e8f61dbcd 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp @@ -9,7 +9,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 54eade30a..88af6b4d1 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp @@ -10,7 +10,7 @@ - + @@ -109,7 +109,7 @@ - + diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 1824a288c..65e17e1c6 100644 --- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp +++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp @@ -10,7 +10,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index e4f20e9ff..c098056d8 100644 --- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp +++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp @@ -9,7 +9,7 @@ - + @@ -53,7 +53,7 @@ - +