mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:48 +00:00
#96 Reformat code with EditorConfig
This commit is contained in:
parent
1aef94d6a8
commit
09ed33a5fc
56 changed files with 831 additions and 832 deletions
9
.editorconfig
Normal file
9
.editorconfig
Normal file
|
@ -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
|
745
pom.xml
745
pom.xml
|
@ -1,406 +1,407 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
<modelVersion>4.0.0</modelVersion>
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<groupId>org.springframework.samples</groupId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>spring-petclinic</artifactId>
|
<groupId>org.springframework.samples</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<artifactId>spring-petclinic</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>petclinic</name>
|
<name>petclinic</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<!-- Generic properties -->
|
<!-- Generic properties -->
|
||||||
<java.version>1.7</java.version>
|
<java.version>1.7</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<spring-io-platform.version>1.1.3.RELEASE</spring-io-platform.version>
|
<spring-io-platform.version>1.1.3.RELEASE</spring-io-platform.version>
|
||||||
<spring-data-jdbc.version>1.1.0.RELEASE</spring-data-jdbc.version>
|
<spring-data-jdbc.version>1.1.0.RELEASE</spring-data-jdbc.version>
|
||||||
|
|
||||||
|
|
||||||
<!-- Java EE / Java SE dependencies -->
|
<!-- Java EE / Java SE dependencies -->
|
||||||
<tomcat.version>7.0.59</tomcat.version>
|
<tomcat.version>7.0.59</tomcat.version>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
<assertj.version>2.2.0</assertj.version>
|
<assertj.version>2.2.0</assertj.version>
|
||||||
|
|
||||||
<!-- Dates -->
|
|
||||||
<jodatime-hibernate.version>1.3</jodatime-hibernate.version>
|
|
||||||
<jodatime-jsptags.version>1.1.1</jodatime-jsptags.version>
|
|
||||||
<jadira-usertype-core.version>3.2.0.GA</jadira-usertype-core.version>
|
|
||||||
|
|
||||||
<!-- MySql -->
|
<!-- Dates -->
|
||||||
<mysql-driver.version>5.1.36</mysql-driver.version>
|
<jodatime-hibernate.version>1.3</jodatime-hibernate.version>
|
||||||
|
<jodatime-jsptags.version>1.1.1</jodatime-jsptags.version>
|
||||||
|
<jadira-usertype-core.version>3.2.0.GA</jadira-usertype-core.version>
|
||||||
|
|
||||||
<!-- Web dependencies -->
|
<!-- MySql -->
|
||||||
<webjars-bootstrap.version>2.3.0</webjars-bootstrap.version>
|
<mysql-driver.version>5.1.36</mysql-driver.version>
|
||||||
<webjars-jquery-ui.version>1.10.3</webjars-jquery-ui.version>
|
|
||||||
<webjars-jquery.version>2.0.3-1</webjars-jquery.version>
|
|
||||||
<dandelion.version>1.0.1</dandelion.version>
|
|
||||||
|
|
||||||
<cobertura.version>2.7</cobertura.version>
|
<!-- Web dependencies -->
|
||||||
|
<webjars-bootstrap.version>2.3.0</webjars-bootstrap.version>
|
||||||
|
<webjars-jquery-ui.version>1.10.3</webjars-jquery-ui.version>
|
||||||
|
<webjars-jquery.version>2.0.3-1</webjars-jquery.version>
|
||||||
|
<dandelion.version>1.0.1</dandelion.version>
|
||||||
|
|
||||||
</properties>
|
<cobertura.version>2.7</cobertura.version>
|
||||||
|
|
||||||
<dependencyManagement>
|
</properties>
|
||||||
<!-- Import the maven Spring IO Platform Bill Of Materials (BOM) -->
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.spring.platform</groupId>
|
|
||||||
<artifactId>platform-bom</artifactId>
|
|
||||||
<version>${spring-io-platform.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencyManagement>
|
||||||
<dependency>
|
<!-- Import the maven Spring IO Platform Bill Of Materials (BOM) -->
|
||||||
<groupId>org.jadira.usertype</groupId>
|
<dependencies>
|
||||||
<artifactId>usertype.core</artifactId>
|
<dependency>
|
||||||
<version>${jadira-usertype-core.version}</version>
|
<groupId>io.spring.platform</groupId>
|
||||||
</dependency>
|
<artifactId>platform-bom</artifactId>
|
||||||
<dependency>
|
<version>${spring-io-platform.version}</version>
|
||||||
<groupId>org.apache.tomcat</groupId>
|
<type>pom</type>
|
||||||
<artifactId>tomcat-servlet-api</artifactId>
|
<scope>import</scope>
|
||||||
<version>${tomcat.version}</version>
|
</dependency>
|
||||||
<scope>provided</scope>
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jadira.usertype</groupId>
|
||||||
|
<artifactId>usertype.core</artifactId>
|
||||||
|
<version>${jadira-usertype-core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
|
<version>${tomcat.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet.jsp</groupId>
|
||||||
|
<artifactId>javax.servlet.jsp-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-jasper-el</artifactId>
|
||||||
|
<version>${tomcat.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet.jsp</groupId>
|
|
||||||
<artifactId>javax.servlet.jsp-api</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat</groupId>
|
|
||||||
<artifactId>tomcat-jasper-el</artifactId>
|
|
||||||
<version>${tomcat.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet.jsp.jstl</groupId>
|
<groupId>javax.servlet.jsp.jstl</groupId>
|
||||||
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
|
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.taglibs</groupId>
|
<groupId>org.apache.taglibs</groupId>
|
||||||
<artifactId>taglibs-standard-jstlel</artifactId>
|
<artifactId>taglibs-standard-jstlel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- JSon -->
|
<!-- JSon -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- SPRING, SPRING, SPRINGITY SPRING -->
|
<!-- SPRING, SPRING, SPRINGITY SPRING -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-jdbc-core</artifactId>
|
<artifactId>spring-data-jdbc-core</artifactId>
|
||||||
<version>${spring-data-jdbc.version}</version>
|
<version>${spring-data-jdbc.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>*</artifactId>
|
<artifactId>*</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<!-- because Spring Data usually comes with a slightly older version of Spring -->
|
<!-- because Spring Data usually comes with a slightly older version of Spring -->
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-jdbc</artifactId>
|
<artifactId>spring-jdbc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- used for EhCacheCacheManager -->
|
<!-- used for EhCacheCacheManager -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-support</artifactId>
|
<artifactId>spring-context-support</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-oxm</artifactId>
|
<artifactId>spring-oxm</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.aspectj</groupId>
|
<groupId>org.aspectj</groupId>
|
||||||
<artifactId>aspectjrt</artifactId>
|
<artifactId>aspectjrt</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.aspectj</groupId>
|
<groupId>org.aspectj</groupId>
|
||||||
<artifactId>aspectjweaver</artifactId>
|
<artifactId>aspectjweaver</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Database connection pool
|
<!-- Database connection pool
|
||||||
See here for more details on commons-dbcp versus tomcat-jdbc:
|
See here for more details on commons-dbcp versus tomcat-jdbc:
|
||||||
http://blog.ippon.fr/2013/03/13/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5/
|
http://blog.ippon.fr/2013/03/13/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5/
|
||||||
-->
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat</groupId>
|
<groupId>org.apache.tomcat</groupId>
|
||||||
<artifactId>tomcat-jdbc</artifactId>
|
<artifactId>tomcat-jdbc</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Logging with SLF4J & LogBack -->
|
<!-- Logging with SLF4J & LogBack -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Date and Time -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time-hibernate</artifactId>
|
|
||||||
<version>${jodatime-hibernate.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time-jsptags</artifactId>
|
|
||||||
<version>${jodatime-jsptags.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Databases - Uses HSQL by default -->
|
<!-- Date and Time -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hsqldb</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>hsqldb</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<scope>runtime</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time-hibernate</artifactId>
|
||||||
|
<version>${jodatime-hibernate.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time-jsptags</artifactId>
|
||||||
|
<version>${jodatime-jsptags.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- For MySql only -->
|
<!-- Databases - Uses HSQL by default -->
|
||||||
<!--dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>org.hsqldb</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>hsqldb</artifactId>
|
||||||
<version>${mysql-driver.version}</version>
|
<scope>runtime</scope>
|
||||||
</dependency-->
|
</dependency>
|
||||||
|
|
||||||
<!-- HIBERNATE -->
|
<!-- For MySql only -->
|
||||||
<dependency>
|
<!--dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
<version>${mysql-driver.version}</version>
|
||||||
<dependency>
|
</dependency-->
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-ehcache</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sf.ehcache</groupId>
|
|
||||||
<artifactId>ehcache-core</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<!-- Webjars (static dependencies distributed as JAR files) -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>bootstrap</artifactId>
|
|
||||||
<version>${webjars-bootstrap.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>jquery-ui</artifactId>
|
|
||||||
<version>${webjars-jquery-ui.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>jquery</artifactId>
|
|
||||||
<version>${webjars-jquery.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test Artifacts -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-core</artifactId>
|
|
||||||
<version>${assertj.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Dandelion -->
|
<!-- HIBERNATE -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.dandelion</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>datatables-jsp</artifactId>
|
<artifactId>hibernate-entitymanager</artifactId>
|
||||||
<version>${dandelion.version}</version>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.hibernate</groupId>
|
||||||
<groupId>com.github.dandelion</groupId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
<artifactId>datatables-export-itext</artifactId>
|
</dependency>
|
||||||
<version>${dandelion.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- temporary fix: below dependency should not be necessary as it is a transitive dependency.
|
|
||||||
For some reason we can't build the app unless it is a first level dependency -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.googlecode.json-simple</groupId>
|
|
||||||
<artifactId>json-simple</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<!-- Maven plugin versions are mentioned in order to guarantee the build reproducibility in the long term -->
|
<dependency>
|
||||||
<build>
|
<groupId>org.hibernate</groupId>
|
||||||
<defaultGoal>install</defaultGoal>
|
<artifactId>hibernate-ehcache</artifactId>
|
||||||
<testResources>
|
</dependency>
|
||||||
<testResource>
|
<dependency>
|
||||||
<!-- declared explicitly so Spring config files can be placed next to their corresponding JUnit test class -->
|
<groupId>net.sf.ehcache</groupId>
|
||||||
<directory>${project.basedir}/src/test/java</directory>
|
<artifactId>ehcache-core</artifactId>
|
||||||
</testResource>
|
<exclusions>
|
||||||
<testResource>
|
<exclusion>
|
||||||
<directory>${project.basedir}/src/test/resources</directory>
|
<groupId>commons-logging</groupId>
|
||||||
</testResource>
|
<artifactId>commons-logging</artifactId>
|
||||||
</testResources>
|
</exclusion>
|
||||||
<plugins>
|
</exclusions>
|
||||||
<plugin>
|
</dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<!-- Webjars (static dependencies distributed as JAR files) -->
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<dependency>
|
||||||
<version>3.0</version>
|
<groupId>org.webjars</groupId>
|
||||||
<configuration>
|
<artifactId>bootstrap</artifactId>
|
||||||
<compilerArguments>
|
<version>${webjars-bootstrap.version}</version>
|
||||||
<Xlint />
|
</dependency>
|
||||||
</compilerArguments>
|
<dependency>
|
||||||
<verbose>true</verbose>
|
<groupId>org.webjars</groupId>
|
||||||
<source>${java.version}</source>
|
<artifactId>jquery-ui</artifactId>
|
||||||
<target>${java.version}</target>
|
<version>${webjars-jquery-ui.version}</version>
|
||||||
<showWarnings>true</showWarnings>
|
</dependency>
|
||||||
</configuration>
|
<dependency>
|
||||||
</plugin>
|
<groupId>org.webjars</groupId>
|
||||||
<plugin>
|
<artifactId>jquery</artifactId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<version>${webjars-jquery.version}</version>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
</dependency>
|
||||||
<version>2.13</version>
|
|
||||||
<configuration>
|
|
||||||
<includes>
|
|
||||||
<include>**/*Tests.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<configuration>
|
|
||||||
<warName>petclinic</warName>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-eclipse-plugin</artifactId>
|
|
||||||
<version>2.9</version>
|
|
||||||
<configuration>
|
|
||||||
<downloadSources>true</downloadSources>
|
|
||||||
<downloadJavadocs>true</downloadJavadocs>
|
|
||||||
<wtpversion>2.0</wtpversion>
|
|
||||||
<sourceIncludes>
|
|
||||||
<sourceInclude>**/*.*</sourceInclude>
|
|
||||||
</sourceIncludes>
|
|
||||||
<additionalBuildcommands>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
</buildCommand>
|
|
||||||
</additionalBuildcommands>
|
|
||||||
<additionalProjectnatures>
|
|
||||||
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
|
|
||||||
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
|
|
||||||
<projectnature>org.eclipse.m2e.core.maven2Nature</projectnature>
|
|
||||||
</additionalProjectnatures>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
|
||||||
<descriptorRefs>
|
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
||||||
</descriptorRefs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.tomcat.maven</groupId>
|
|
||||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
|
||||||
<version>2.2</version>
|
|
||||||
<configuration>
|
|
||||||
<server>tomcat-development-server</server>
|
|
||||||
<port>9966</port>
|
|
||||||
<path>/petclinic</path>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
|
||||||
<version>${cobertura.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<check/>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>clean</goal>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<reporting>
|
|
||||||
<plugins>
|
|
||||||
|
|
||||||
<!-- integrate maven-cobertura-plugin to project site -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
|
||||||
<version>${cobertura.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<formats>
|
|
||||||
<format>html</format>
|
|
||||||
</formats>
|
|
||||||
<check/>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</reporting>
|
|
||||||
|
|
||||||
<url>demopetclinic</url>
|
<!-- Test Artifacts -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Dandelion -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.dandelion</groupId>
|
||||||
|
<artifactId>datatables-jsp</artifactId>
|
||||||
|
<version>${dandelion.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.dandelion</groupId>
|
||||||
|
<artifactId>datatables-export-itext</artifactId>
|
||||||
|
<version>${dandelion.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- temporary fix: below dependency should not be necessary as it is a transitive dependency.
|
||||||
|
For some reason we can't build the app unless it is a first level dependency -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.json-simple</groupId>
|
||||||
|
<artifactId>json-simple</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<!-- Maven plugin versions are mentioned in order to guarantee the build reproducibility in the long term -->
|
||||||
|
<build>
|
||||||
|
<defaultGoal>install</defaultGoal>
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<!-- declared explicitly so Spring config files can be placed next to their corresponding JUnit test class -->
|
||||||
|
<directory>${project.basedir}/src/test/java</directory>
|
||||||
|
</testResource>
|
||||||
|
<testResource>
|
||||||
|
<directory>${project.basedir}/src/test/resources</directory>
|
||||||
|
</testResource>
|
||||||
|
</testResources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerArguments>
|
||||||
|
<Xlint/>
|
||||||
|
</compilerArguments>
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<showWarnings>true</showWarnings>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.13</version>
|
||||||
|
<configuration>
|
||||||
|
<includes>
|
||||||
|
<include>**/*Tests.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
<configuration>
|
||||||
|
<warName>petclinic</warName>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
|
<version>2.9</version>
|
||||||
|
<configuration>
|
||||||
|
<downloadSources>true</downloadSources>
|
||||||
|
<downloadJavadocs>true</downloadJavadocs>
|
||||||
|
<wtpversion>2.0</wtpversion>
|
||||||
|
<sourceIncludes>
|
||||||
|
<sourceInclude>**/*.*</sourceInclude>
|
||||||
|
</sourceIncludes>
|
||||||
|
<additionalBuildcommands>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
</buildCommand>
|
||||||
|
</additionalBuildcommands>
|
||||||
|
<additionalProjectnatures>
|
||||||
|
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
|
||||||
|
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
|
||||||
|
<projectnature>org.eclipse.m2e.core.maven2Nature</projectnature>
|
||||||
|
</additionalProjectnatures>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<configuration>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.tomcat.maven</groupId>
|
||||||
|
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||||
|
<version>2.2</version>
|
||||||
|
<configuration>
|
||||||
|
<server>tomcat-development-server</server>
|
||||||
|
<port>9966</port>
|
||||||
|
<path>/petclinic</path>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>${cobertura.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<check/>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>clean</goal>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
|
||||||
|
<!-- integrate maven-cobertura-plugin to project site -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>${cobertura.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<formats>
|
||||||
|
<format>html</format>
|
||||||
|
</formats>
|
||||||
|
<check/>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
|
<url>demopetclinic</url>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -32,15 +32,14 @@ public class BaseEntity {
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
protected Integer id;
|
protected Integer id;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
public void setId(Integer id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNew() {
|
public boolean isNew() {
|
||||||
return (this.id == null);
|
return (this.id == null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,15 +32,14 @@ public class NamedEntity extends BaseEntity {
|
||||||
@Column(name = "name")
|
@Column(name = "name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getName();
|
return this.getName();
|
||||||
|
|
|
@ -85,10 +85,6 @@ public class Owner extends Person {
|
||||||
this.telephone = telephone;
|
this.telephone = telephone;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setPetsInternal(Set<Pet> pets) {
|
|
||||||
this.pets = pets;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Set<Pet> getPetsInternal() {
|
protected Set<Pet> getPetsInternal() {
|
||||||
if (this.pets == null) {
|
if (this.pets == null) {
|
||||||
this.pets = new HashSet<>();
|
this.pets = new HashSet<>();
|
||||||
|
@ -96,6 +92,10 @@ public class Owner extends Person {
|
||||||
return this.pets;
|
return this.pets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setPetsInternal(Set<Pet> pets) {
|
||||||
|
this.pets = pets;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Pet> getPets() {
|
public List<Pet> getPets() {
|
||||||
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
|
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
|
||||||
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
|
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
|
||||||
|
@ -141,13 +141,13 @@ public class Owner extends Person {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringCreator(this)
|
return new ToStringCreator(this)
|
||||||
|
|
||||||
.append("id", this.getId())
|
.append("id", this.getId())
|
||||||
.append("new", this.isNew())
|
.append("new", this.isNew())
|
||||||
.append("lastName", this.getLastName())
|
.append("lastName", this.getLastName())
|
||||||
.append("firstName", this.getFirstName())
|
.append("firstName", this.getFirstName())
|
||||||
.append("address", this.address)
|
.append("address", this.address)
|
||||||
.append("city", this.city)
|
.append("city", this.city)
|
||||||
.append("telephone", this.telephone)
|
.append("telephone", this.telephone)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,33 +63,28 @@ public class Pet extends NamedEntity {
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
|
||||||
private Set<Visit> visits;
|
private Set<Visit> visits;
|
||||||
|
|
||||||
|
|
||||||
public void setBirthDate(DateTime birthDate) {
|
|
||||||
this.birthDate = birthDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime getBirthDate() {
|
public DateTime getBirthDate() {
|
||||||
return this.birthDate;
|
return this.birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(PetType type) {
|
public void setBirthDate(DateTime birthDate) {
|
||||||
this.type = type;
|
this.birthDate = birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PetType getType() {
|
public PetType getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setOwner(Owner owner) {
|
public void setType(PetType type) {
|
||||||
this.owner = owner;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Owner getOwner() {
|
public Owner getOwner() {
|
||||||
return this.owner;
|
return this.owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setVisitsInternal(Set<Visit> visits) {
|
protected void setOwner(Owner owner) {
|
||||||
this.visits = visits;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<Visit> getVisitsInternal() {
|
protected Set<Visit> getVisitsInternal() {
|
||||||
|
@ -99,6 +94,10 @@ public class Pet extends NamedEntity {
|
||||||
return this.visits;
|
return this.visits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setVisitsInternal(Set<Visit> visits) {
|
||||||
|
this.visits = visits;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Visit> getVisits() {
|
public List<Visit> getVisits() {
|
||||||
List<Visit> sortedVisits = new ArrayList<>(getVisitsInternal());
|
List<Visit> sortedVisits = new ArrayList<>(getVisitsInternal());
|
||||||
PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false));
|
PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false));
|
||||||
|
|
|
@ -20,7 +20,7 @@ import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* Can be Cat, Dog, Hamster...
|
* Can be Cat, Dog, Hamster...
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "types")
|
@Table(name = "types")
|
||||||
|
|
|
@ -46,14 +46,9 @@ public class Vet extends Person {
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"),
|
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
||||||
private Set<Specialty> specialties;
|
private Set<Specialty> specialties;
|
||||||
|
|
||||||
|
|
||||||
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
|
|
||||||
this.specialties = specialties;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Set<Specialty> getSpecialtiesInternal() {
|
protected Set<Specialty> getSpecialtiesInternal() {
|
||||||
if (this.specialties == null) {
|
if (this.specialties == null) {
|
||||||
this.specialties = new HashSet<>();
|
this.specialties = new HashSet<>();
|
||||||
|
@ -61,6 +56,10 @@ public class Vet extends Person {
|
||||||
return this.specialties;
|
return this.specialties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
|
||||||
|
this.specialties = specialties;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public List<Specialty> getSpecialties() {
|
public List<Specialty> getSpecialties() {
|
||||||
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
|
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* The classes in this package represent PetClinic's business layer.
|
* The classes in this package represent PetClinic's business layer.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.model;
|
package org.springframework.samples.petclinic.model;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public interface OwnerRepository {
|
||||||
*
|
*
|
||||||
* @param lastName Value to search for
|
* @param lastName Value to search for
|
||||||
* @return a <code>Collection</code> of matching <code>Owner</code>s (or an empty <code>Collection</code> if none
|
* @return a <code>Collection</code> of matching <code>Owner</code>s (or an empty <code>Collection</code> if none
|
||||||
* found)
|
* found)
|
||||||
*/
|
*/
|
||||||
Collection<Owner> findByLastName(String lastName) throws DataAccessException;
|
Collection<Owner> findByLastName(String lastName) throws DataAccessException;
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ public interface OwnerRepository {
|
||||||
*
|
*
|
||||||
* @param id the id to search for
|
* @param id the id to search for
|
||||||
* @return the <code>Owner</code> if found
|
* @return the <code>Owner</code> if found
|
||||||
* @throws org.springframework.dao.DataRetrievalFailureException
|
* @throws org.springframework.dao.DataRetrievalFailureException if not found
|
||||||
* if not found
|
|
||||||
*/
|
*/
|
||||||
Owner findById(int id) throws DataAccessException;
|
Owner findById(int id) throws DataAccessException;
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,7 @@ public interface PetRepository {
|
||||||
*
|
*
|
||||||
* @param id the id to search for
|
* @param id the id to search for
|
||||||
* @return the <code>Pet</code> if found
|
* @return the <code>Pet</code> if found
|
||||||
* @throws org.springframework.dao.DataRetrievalFailureException
|
* @throws org.springframework.dao.DataRetrievalFailureException if not found
|
||||||
* if not found
|
|
||||||
*/
|
*/
|
||||||
Pet findById(int id) throws DataAccessException;
|
Pet findById(int id) throws DataAccessException;
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
public JdbcOwnerRepositoryImpl(DataSource dataSource, NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public JdbcOwnerRepositoryImpl(DataSource dataSource, NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
|
||||||
this.insertOwner = new SimpleJdbcInsert(dataSource)
|
this.insertOwner = new SimpleJdbcInsert(dataSource)
|
||||||
.withTableName("owners")
|
.withTableName("owners")
|
||||||
.usingGeneratedKeyColumns("id");
|
.usingGeneratedKeyColumns("id");
|
||||||
|
|
||||||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("lastName", lastName + "%");
|
params.put("lastName", lastName + "%");
|
||||||
List<Owner> owners = this.namedParameterJdbcTemplate.query(
|
List<Owner> owners = this.namedParameterJdbcTemplate.query(
|
||||||
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName",
|
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName",
|
||||||
params,
|
params,
|
||||||
BeanPropertyRowMapper.newInstance(Owner.class)
|
BeanPropertyRowMapper.newInstance(Owner.class)
|
||||||
);
|
);
|
||||||
loadOwnersPetsAndVisits(owners);
|
loadOwnersPetsAndVisits(owners);
|
||||||
return owners;
|
return owners;
|
||||||
|
@ -96,9 +96,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("id", id);
|
params.put("id", id);
|
||||||
owner = this.namedParameterJdbcTemplate.queryForObject(
|
owner = this.namedParameterJdbcTemplate.queryForObject(
|
||||||
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
|
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
|
||||||
params,
|
params,
|
||||||
BeanPropertyRowMapper.newInstance(Owner.class)
|
BeanPropertyRowMapper.newInstance(Owner.class)
|
||||||
);
|
);
|
||||||
} catch (EmptyResultDataAccessException ex) {
|
} catch (EmptyResultDataAccessException ex) {
|
||||||
throw new ObjectRetrievalFailureException(Owner.class, id);
|
throw new ObjectRetrievalFailureException(Owner.class, id);
|
||||||
|
@ -111,9 +111,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("id", owner.getId());
|
params.put("id", owner.getId());
|
||||||
final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
|
final List<JdbcPet> 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",
|
"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,
|
params,
|
||||||
new JdbcPetVisitExtractor()
|
new JdbcPetVisitExtractor()
|
||||||
);
|
);
|
||||||
Collection<PetType> petTypes = getPetTypes();
|
Collection<PetType> petTypes = getPetTypes();
|
||||||
for (JdbcPet pet : pets) {
|
for (JdbcPet pet : pets) {
|
||||||
|
@ -130,16 +130,16 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
owner.setId(newKey.intValue());
|
owner.setId(newKey.intValue());
|
||||||
} else {
|
} else {
|
||||||
this.namedParameterJdbcTemplate.update(
|
this.namedParameterJdbcTemplate.update(
|
||||||
"UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, " +
|
"UPDATE owners SET first_name=:firstName, last_name=:lastName, address=:address, " +
|
||||||
"city=:city, telephone=:telephone WHERE id=:id",
|
"city=:city, telephone=:telephone WHERE id=:id",
|
||||||
parameterSource);
|
parameterSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<PetType> getPetTypes() throws DataAccessException {
|
public Collection<PetType> getPetTypes() throws DataAccessException {
|
||||||
return this.namedParameterJdbcTemplate.query(
|
return this.namedParameterJdbcTemplate.query(
|
||||||
"SELECT id, name FROM types ORDER BY name", new HashMap<String, Object>(),
|
"SELECT id, name FROM types ORDER BY name", new HashMap<String, Object>(),
|
||||||
BeanPropertyRowMapper.newInstance(PetType.class));
|
BeanPropertyRowMapper.newInstance(PetType.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,21 +29,20 @@ class JdbcPet extends Pet {
|
||||||
|
|
||||||
private int ownerId;
|
private int ownerId;
|
||||||
|
|
||||||
|
|
||||||
public void setTypeId(int typeId) {
|
|
||||||
this.typeId = typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTypeId() {
|
public int getTypeId() {
|
||||||
return this.typeId;
|
return this.typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwnerId(int ownerId) {
|
public void setTypeId(int typeId) {
|
||||||
this.ownerId = ownerId;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOwnerId() {
|
public int getOwnerId() {
|
||||||
return this.ownerId;
|
return this.ownerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOwnerId(int ownerId) {
|
||||||
|
this.ownerId = ownerId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,8 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||||
|
|
||||||
this.insertPet = new SimpleJdbcInsert(dataSource)
|
this.insertPet = new SimpleJdbcInsert(dataSource)
|
||||||
.withTableName("pets")
|
.withTableName("pets")
|
||||||
.usingGeneratedKeyColumns("id");
|
.usingGeneratedKeyColumns("id");
|
||||||
|
|
||||||
this.ownerRepository = ownerRepository;
|
this.ownerRepository = ownerRepository;
|
||||||
this.visitRepository = visitRepository;
|
this.visitRepository = visitRepository;
|
||||||
|
@ -75,9 +75,9 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
public List<PetType> findPetTypes() throws DataAccessException {
|
public List<PetType> findPetTypes() throws DataAccessException {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
return this.namedParameterJdbcTemplate.query(
|
return this.namedParameterJdbcTemplate.query(
|
||||||
"SELECT id, name FROM types ORDER BY name",
|
"SELECT id, name FROM types ORDER BY name",
|
||||||
params,
|
params,
|
||||||
BeanPropertyRowMapper.newInstance(PetType.class));
|
BeanPropertyRowMapper.newInstance(PetType.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,9 +87,9 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("id", id);
|
params.put("id", id);
|
||||||
pet = this.namedParameterJdbcTemplate.queryForObject(
|
pet = this.namedParameterJdbcTemplate.queryForObject(
|
||||||
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
|
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
|
||||||
params,
|
params,
|
||||||
new JdbcPetRowMapper());
|
new JdbcPetRowMapper());
|
||||||
} catch (EmptyResultDataAccessException ex) {
|
} catch (EmptyResultDataAccessException ex) {
|
||||||
throw new ObjectRetrievalFailureException(Pet.class, id);
|
throw new ObjectRetrievalFailureException(Pet.class, id);
|
||||||
}
|
}
|
||||||
|
@ -108,13 +108,13 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
public void save(Pet pet) throws DataAccessException {
|
public void save(Pet pet) throws DataAccessException {
|
||||||
if (pet.isNew()) {
|
if (pet.isNew()) {
|
||||||
Number newKey = this.insertPet.executeAndReturnKey(
|
Number newKey = this.insertPet.executeAndReturnKey(
|
||||||
createPetParameterSource(pet));
|
createPetParameterSource(pet));
|
||||||
pet.setId(newKey.intValue());
|
pet.setId(newKey.intValue());
|
||||||
} else {
|
} else {
|
||||||
this.namedParameterJdbcTemplate.update(
|
this.namedParameterJdbcTemplate.update(
|
||||||
"UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
|
"UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
|
||||||
"owner_id=:owner_id WHERE id=:id",
|
"owner_id=:owner_id WHERE id=:id",
|
||||||
createPetParameterSource(pet));
|
createPetParameterSource(pet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,11 +123,11 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
*/
|
*/
|
||||||
private MapSqlParameterSource createPetParameterSource(Pet pet) {
|
private MapSqlParameterSource createPetParameterSource(Pet pet) {
|
||||||
return new MapSqlParameterSource()
|
return new MapSqlParameterSource()
|
||||||
.addValue("id", pet.getId())
|
.addValue("id", pet.getId())
|
||||||
.addValue("name", pet.getName())
|
.addValue("name", pet.getName())
|
||||||
.addValue("birth_date", pet.getBirthDate().toDate())
|
.addValue("birth_date", pet.getBirthDate().toDate())
|
||||||
.addValue("type_id", pet.getType().getId())
|
.addValue("type_id", pet.getType().getId())
|
||||||
.addValue("owner_id", pet.getOwner().getId());
|
.addValue("owner_id", pet.getOwner().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.sql.SQLException;
|
||||||
* {@link OneToManyResultSetExtractor} of Spring Data Core JDBC Extensions.
|
* {@link OneToManyResultSetExtractor} of Spring Data Core JDBC Extensions.
|
||||||
*/
|
*/
|
||||||
public class JdbcPetVisitExtractor extends
|
public class JdbcPetVisitExtractor extends
|
||||||
OneToManyResultSetExtractor<JdbcPet, Visit, Integer> {
|
OneToManyResultSetExtractor<JdbcPet, Visit, Integer> {
|
||||||
|
|
||||||
public JdbcPetVisitExtractor() {
|
public JdbcPetVisitExtractor() {
|
||||||
super(new JdbcPetRowMapper(), new JdbcVisitRowMapper());
|
super(new JdbcPetRowMapper(), new JdbcVisitRowMapper());
|
||||||
|
@ -51,4 +51,4 @@ public class JdbcPetVisitExtractor extends
|
||||||
protected void addChild(JdbcPet root, Visit child) {
|
protected void addChild(JdbcPet root, Visit child) {
|
||||||
root.addVisit(child);
|
root.addVisit(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,25 +60,25 @@ public class JdbcVetRepositoryImpl implements VetRepository {
|
||||||
List<Vet> vets = new ArrayList<>();
|
List<Vet> vets = new ArrayList<>();
|
||||||
// Retrieve the list of all vets.
|
// Retrieve the list of all vets.
|
||||||
vets.addAll(this.jdbcTemplate.query(
|
vets.addAll(this.jdbcTemplate.query(
|
||||||
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
|
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
|
||||||
BeanPropertyRowMapper.newInstance(Vet.class)));
|
BeanPropertyRowMapper.newInstance(Vet.class)));
|
||||||
|
|
||||||
// Retrieve the list of all possible specialties.
|
// Retrieve the list of all possible specialties.
|
||||||
final List<Specialty> specialties = this.jdbcTemplate.query(
|
final List<Specialty> specialties = this.jdbcTemplate.query(
|
||||||
"SELECT id, name FROM specialties",
|
"SELECT id, name FROM specialties",
|
||||||
BeanPropertyRowMapper.newInstance(Specialty.class));
|
BeanPropertyRowMapper.newInstance(Specialty.class));
|
||||||
|
|
||||||
// Build each vet's list of specialties.
|
// Build each vet's list of specialties.
|
||||||
for (Vet vet : vets) {
|
for (Vet vet : vets) {
|
||||||
final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
|
final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
|
||||||
"SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
|
"SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
|
||||||
new BeanPropertyRowMapper<Integer>() {
|
new BeanPropertyRowMapper<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer mapRow(ResultSet rs, int row) throws SQLException {
|
public Integer mapRow(ResultSet rs, int row) throws SQLException {
|
||||||
return rs.getInt(1);
|
return rs.getInt(1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
vet.getId());
|
vet.getId());
|
||||||
for (int specialtyId : vetSpecialtiesIds) {
|
for (int specialtyId : vetSpecialtiesIds) {
|
||||||
Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
|
Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
|
||||||
vet.addSpecialty(specialty);
|
vet.addSpecialty(specialty);
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
this.insertVisit = new SimpleJdbcInsert(dataSource)
|
this.insertVisit = new SimpleJdbcInsert(dataSource)
|
||||||
.withTableName("visits")
|
.withTableName("visits")
|
||||||
.usingGeneratedKeyColumns("id");
|
.usingGeneratedKeyColumns("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
||||||
public void save(Visit visit) throws DataAccessException {
|
public void save(Visit visit) throws DataAccessException {
|
||||||
if (visit.isNew()) {
|
if (visit.isNew()) {
|
||||||
Number newKey = this.insertVisit.executeAndReturnKey(
|
Number newKey = this.insertVisit.executeAndReturnKey(
|
||||||
createVisitParameterSource(visit));
|
createVisitParameterSource(visit));
|
||||||
visit.setId(newKey.intValue());
|
visit.setId(newKey.intValue());
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("Visit update not supported");
|
throw new UnsupportedOperationException("Visit update not supported");
|
||||||
|
@ -72,17 +72,17 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
||||||
*/
|
*/
|
||||||
private MapSqlParameterSource createVisitParameterSource(Visit visit) {
|
private MapSqlParameterSource createVisitParameterSource(Visit visit) {
|
||||||
return new MapSqlParameterSource()
|
return new MapSqlParameterSource()
|
||||||
.addValue("id", visit.getId())
|
.addValue("id", visit.getId())
|
||||||
.addValue("visit_date", visit.getDate().toDate())
|
.addValue("visit_date", visit.getDate().toDate())
|
||||||
.addValue("description", visit.getDescription())
|
.addValue("description", visit.getDescription())
|
||||||
.addValue("pet_id", visit.getPet().getId());
|
.addValue("pet_id", visit.getPet().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Visit> findByPetId(Integer petId) {
|
public List<Visit> findByPetId(Integer petId) {
|
||||||
return this.jdbcTemplate.query(
|
return this.jdbcTemplate.query(
|
||||||
"SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=?",
|
"SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=?",
|
||||||
new JdbcVisitRowMapper(), petId);
|
new JdbcVisitRowMapper(), petId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* The classes in this package represent the JDBC implementation
|
* The classes in this package represent the JDBC implementation
|
||||||
* of PetClinic's persistence layer.
|
* of PetClinic's persistence layer.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.repository.jdbc;
|
package org.springframework.samples.petclinic.repository.jdbc;
|
||||||
|
|
||||||
|
|
|
@ -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).
|
* 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:
|
* There are some ways to improve it such as:
|
||||||
* - creating a Ligtweight class (example here: https://community.jboss.org/wiki/LightweightClass)
|
* - creating a Ligtweight class (example here: https://community.jboss.org/wiki/LightweightClass)
|
||||||
|
@ -70,12 +70,11 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Owner owner) {
|
public void save(Owner owner) {
|
||||||
if (owner.getId() == null) {
|
if (owner.getId() == null) {
|
||||||
this.em.persist(owner);
|
this.em.persist(owner);
|
||||||
}
|
} else {
|
||||||
else {
|
this.em.merge(owner);
|
||||||
this.em.merge(owner);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,11 @@ public class JpaPetRepositoryImpl implements PetRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Pet pet) {
|
public void save(Pet pet) {
|
||||||
if (pet.getId() == null) {
|
if (pet.getId() == null) {
|
||||||
this.em.persist(pet);
|
this.em.persist(pet);
|
||||||
}
|
} else {
|
||||||
else {
|
this.em.merge(pet);
|
||||||
this.em.merge(pet);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,11 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Visit visit) {
|
public void save(Visit visit) {
|
||||||
if (visit.getId() == null) {
|
if (visit.getId() == null) {
|
||||||
this.em.persist(visit);
|
this.em.persist(visit);
|
||||||
}
|
} else {
|
||||||
else {
|
this.em.merge(visit);
|
||||||
this.em.merge(visit);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* The classes in this package represent the JPA implementation
|
* The classes in this package represent the JPA implementation
|
||||||
* of PetClinic's persistence layer.
|
* of PetClinic's persistence layer.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.repository.jpa;
|
package org.springframework.samples.petclinic.repository.jpa;
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||||
* @since 15.1.2013
|
* @since 15.1.2013
|
||||||
*/
|
*/
|
||||||
public interface SpringDataOwnerRepository extends OwnerRepository, Repository<Owner, Integer> {
|
public interface SpringDataOwnerRepository extends OwnerRepository, Repository<Owner, Integer> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%")
|
@Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%")
|
||||||
public Collection<Owner> findByLastName(@Param("lastName") String lastName);
|
public Collection<Owner> findByLastName(@Param("lastName") String lastName);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id")
|
@Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id")
|
||||||
public Owner findById(@Param("id") int id);
|
public Owner findById(@Param("id") int id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* 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
|
* monitored using any JMX console such as the jConsole
|
||||||
*
|
* <p/>
|
||||||
* 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 Rob Harrop
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
@ -44,17 +44,16 @@ public class CallMonitoringAspect {
|
||||||
|
|
||||||
private long accumulatedCallTime = 0;
|
private long accumulatedCallTime = 0;
|
||||||
|
|
||||||
|
|
||||||
@ManagedAttribute
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManagedAttribute
|
@ManagedAttribute
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManagedAttribute
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
@ManagedOperation
|
@ManagedOperation
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.callCount = 0;
|
this.callCount = 0;
|
||||||
|
@ -68,10 +67,10 @@ public class CallMonitoringAspect {
|
||||||
|
|
||||||
@ManagedAttribute
|
@ManagedAttribute
|
||||||
public long getCallTime() {
|
public long getCallTime() {
|
||||||
if (this.callCount > 0)
|
if (this.callCount > 0)
|
||||||
return this.accumulatedCallTime / this.callCount;
|
return this.accumulatedCallTime / this.callCount;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,10 @@ public abstract class EntityUtils {
|
||||||
* @param entityClass the entity class to look up
|
* @param entityClass the entity class to look up
|
||||||
* @param entityId the entity id to look up
|
* @param entityId the entity id to look up
|
||||||
* @return the found entity
|
* @return the found entity
|
||||||
* @throws ObjectRetrievalFailureException
|
* @throws ObjectRetrievalFailureException if the entity was not found
|
||||||
* if the entity was not found
|
|
||||||
*/
|
*/
|
||||||
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
|
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
|
||||||
throws ObjectRetrievalFailureException {
|
throws ObjectRetrievalFailureException {
|
||||||
for (T entity : entities) {
|
for (T entity : entities) {
|
||||||
if (entity.getId() == entityId && entityClass.isInstance(entity)) {
|
if (entity.getId() == entityId && entityClass.isInstance(entity)) {
|
||||||
return entity;
|
return entity;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CrashController {
|
||||||
@RequestMapping(value = "/oups", method = RequestMethod.GET)
|
@RequestMapping(value = "/oups", method = RequestMethod.GET)
|
||||||
public String triggerException() {
|
public String triggerException() {
|
||||||
throw new RuntimeException("Expected: controller used to showcase what " +
|
throw new RuntimeException("Expected: controller used to showcase what " +
|
||||||
"happens when an exception is thrown");
|
"happens when an exception is thrown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -96,19 +96,17 @@ public class OwnerController {
|
||||||
// no owners found
|
// no owners found
|
||||||
result.rejectValue("lastName", "notFound", "not found");
|
result.rejectValue("lastName", "notFound", "not found");
|
||||||
return "owners/findOwners";
|
return "owners/findOwners";
|
||||||
}
|
} else if (results.size() == 1) {
|
||||||
else if (results.size() == 1) {
|
// 1 owner found
|
||||||
// 1 owner found
|
owner = results.iterator().next();
|
||||||
owner = results.iterator().next();
|
return "redirect:/owners/" + owner.getId();
|
||||||
return "redirect:/owners/" + owner.getId();
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
// multiple owners found
|
// multiple owners found
|
||||||
model.put("selections", results);
|
model.put("selections", results);
|
||||||
return "owners/ownersList";
|
return "owners/ownersList";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.GET)
|
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.GET)
|
||||||
public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||||
Owner owner = this.clinicService.findOwnerById(ownerId);
|
Owner owner = this.clinicService.findOwnerById(ownerId);
|
||||||
|
|
|
@ -41,14 +41,14 @@ public class PetValidator implements Validator {
|
||||||
} else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) {
|
} else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) {
|
||||||
errors.rejectValue("name", "duplicate", "already exists");
|
errors.rejectValue("name", "duplicate", "already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
// type validation
|
// type validation
|
||||||
if (pet.isNew() && pet.getType() == null) {
|
if (pet.isNew() && pet.getType() == null) {
|
||||||
errors.rejectValue("type", "required", "required");
|
errors.rejectValue("type", "required", "required");
|
||||||
}
|
}
|
||||||
|
|
||||||
// birth date validation
|
// birth date validation
|
||||||
if (pet.getBirthDate()==null) {
|
if (pet.getBirthDate() == null) {
|
||||||
errors.rejectValue("birthDate", "required", "required");
|
errors.rejectValue("birthDate", "required", "required");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,19 +41,21 @@ public class VetController {
|
||||||
this.clinicService = clinicService;
|
this.clinicService = clinicService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value={"/vets.xml","/vets.html"})
|
@RequestMapping(value = {"/vets.xml", "/vets.html"})
|
||||||
public String showVetList(Map<String, Object> model) {
|
public String showVetList(Map<String, Object> 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
|
// so it is simpler for Object-Xml mapping
|
||||||
Vets vets = new Vets();
|
Vets vets = new Vets();
|
||||||
vets.getVetList().addAll(this.clinicService.findVets());
|
vets.getVetList().addAll(this.clinicService.findVets());
|
||||||
model.put("vets", vets);
|
model.put("vets", vets);
|
||||||
return "vets/vetList";
|
return "vets/vetList";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/vets.json")
|
@RequestMapping("/vets.json")
|
||||||
public @ResponseBody Vets showResourcesVetList() {
|
public
|
||||||
// Here we are returning an object of type 'Vets' rather than a collection of Vet objects
|
@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
|
// so it is simpler for JSon/Object mapping
|
||||||
Vets vets = new Vets();
|
Vets vets = new Vets();
|
||||||
vets.getVetList().addAll(this.clinicService.findVets());
|
vets.getVetList().addAll(this.clinicService.findVets());
|
||||||
|
|
|
@ -53,13 +53,14 @@ public class VisitController {
|
||||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||||
dataBinder.setDisallowedFields("id");
|
dataBinder.setDisallowedFields("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before each and every @RequestMapping annotated method.
|
* Called before each and every @RequestMapping annotated method.
|
||||||
* 2 goals:
|
* 2 goals:
|
||||||
* - Make sure we always have fresh data
|
* - Make sure we always have fresh data
|
||||||
* - Since we do not use the session scope, make sure that Pet object always has an id
|
* - 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)
|
* (Even though id is not part of the form fields)
|
||||||
|
*
|
||||||
* @param petId
|
* @param petId
|
||||||
* @return Pet
|
* @return Pet
|
||||||
*/
|
*/
|
||||||
|
@ -67,17 +68,17 @@ public class VisitController {
|
||||||
public Visit loadPetWithVisit(@PathVariable("petId") int petId) {
|
public Visit loadPetWithVisit(@PathVariable("petId") int petId) {
|
||||||
Pet pet = this.clinicService.findPetById(petId);
|
Pet pet = this.clinicService.findPetById(petId);
|
||||||
Visit visit = new Visit();
|
Visit visit = new Visit();
|
||||||
pet.addVisit(visit);
|
pet.addVisit(visit);
|
||||||
return 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)
|
@RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET)
|
||||||
public String initNewVisitForm(@PathVariable("petId") int petId, Map<String, Object> model) {
|
public String initNewVisitForm(@PathVariable("petId") int petId, Map<String, Object> model) {
|
||||||
return "pets/createOrUpdateVisitForm";
|
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)
|
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST)
|
||||||
public String processNewVisitForm(@Valid Visit visit, BindingResult result) {
|
public String processNewVisitForm(@Valid Visit visit, BindingResult result) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* The classes in this package represent PetClinic's web presentation layer.
|
* The classes in this package represent PetClinic's web presentation layer.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.web;
|
package org.springframework.samples.petclinic.web;
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,53 @@
|
||||||
<head>
|
<head>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
table.speakersTable {
|
table.speakersTable {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
padding: 10;
|
padding: 10;
|
||||||
spacing: 10;
|
spacing: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.speakerPic {
|
img.speakerPic {
|
||||||
float: right;
|
float: right;
|
||||||
padding:10;
|
padding: 10;
|
||||||
width: 90;
|
width: 90;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<h1>Organisation</h1>
|
<h1>Organisation</h1>
|
||||||
|
|
||||||
<h1>Speakers</h1>
|
<h1>Speakers</h1>
|
||||||
<table class="speakersTable">
|
<table class="speakersTable">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<img class="speakerPic" alt="Sergiu Bodiu" src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg" />
|
<img class="speakerPic" alt="Sergiu Bodiu"
|
||||||
<h2>Sergiu Bodiu </h2>
|
src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg"/>
|
||||||
<h3> Java Consultant at Bank of America </h3>
|
|
||||||
<font size="5">S</font>easoned 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.
|
<h2>Sergiu Bodiu </h2>
|
||||||
</td>
|
|
||||||
</tr>
|
<h3> Java Consultant at Bank of America </h3>
|
||||||
<tr>
|
<font size="5">S</font>easoned consultant experienced in large-scale e-commerce projects, passionate about
|
||||||
<td>
|
providing innovative technology solutions to solve complex business problems, have extensive knowledge and
|
||||||
<img alt="Sergiu Bodiu" src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg" width="84" height="84" align="right" hspace="10"/>
|
experience delivering enterprise wide applications. He is skilled in software design, data modeling,
|
||||||
<h2>Sergiu Bodiu </h2>
|
stakeholder management, IT strategic planning, technical know-how and security. Able to design, implement,
|
||||||
<h3> Java Consultant at Bank of America </h3>
|
test and maintain software product components with strong focus on design elegance and software reuse.
|
||||||
<font size="5">S</font>easoned 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.
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
</tbody>
|
<td>
|
||||||
|
<img alt="Sergiu Bodiu" src="http://m.c.lnkd.licdn.com/mpr/mpr/shrink_200_200/p/4/000/16a/2ba/0ba653e.jpg"
|
||||||
|
width="84" height="84" align="right" hspace="10"/>
|
||||||
|
|
||||||
|
<h2>Sergiu Bodiu </h2>
|
||||||
|
|
||||||
|
<h3> Java Consultant at Bank of America </h3>
|
||||||
|
<font size="5">S</font>easoned 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.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!--<logger name="org.hibernate" level="debug"/> -->
|
<!--<logger name="org.hibernate" level="debug"/> -->
|
||||||
<logger name="org.springframework.samples.petclinic" level="debug"/>
|
<logger name="org.springframework.samples.petclinic" level="debug"/>
|
||||||
|
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="console"/>
|
<appender-ref ref="console"/>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -2,36 +2,36 @@
|
||||||
<!--
|
<!--
|
||||||
Repository and Service layers
|
Repository and Service layers
|
||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns="http://www.springframework.org/schema/beans"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
|
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
||||||
|
|
||||||
<!-- import the dataSource definition -->
|
<!-- import the dataSource definition -->
|
||||||
<import resource="datasource-config.xml"/>
|
<import resource="datasource-config.xml"/>
|
||||||
|
|
||||||
<context:component-scan
|
<context:component-scan
|
||||||
base-package="org.springframework.samples.petclinic.service"/>
|
base-package="org.springframework.samples.petclinic.service"/>
|
||||||
|
|
||||||
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
||||||
<!-- (in this case, JDBC-related settings for the JPA EntityManager definition below) -->
|
<!-- (in this case, JDBC-related settings for the JPA EntityManager definition below) -->
|
||||||
<context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/>
|
<context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/>
|
||||||
|
|
||||||
<!-- enables scanning for @Transactional annotations -->
|
<!-- enables scanning for @Transactional annotations -->
|
||||||
<tx:annotation-driven />
|
<tx:annotation-driven/>
|
||||||
|
|
||||||
|
|
||||||
<!-- ================== 3 Profiles to choose from ===================
|
<!-- ================== 3 Profiles to choose from ===================
|
||||||
- jdbc (uses Spring" JdbcTemplate)
|
- jdbc (uses Spring" JdbcTemplate)
|
||||||
- jpa
|
- jpa
|
||||||
- spring-data-jpa
|
- spring-data-jpa
|
||||||
=============================================================================-->
|
=============================================================================-->
|
||||||
|
|
||||||
<beans profile="jpa,spring-data-jpa">
|
<beans profile="jpa,spring-data-jpa">
|
||||||
<!-- JPA EntityManagerFactory -->
|
<!-- JPA EntityManagerFactory -->
|
||||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
<!-- the 'database' parameter refers to the database dialect being used.
|
<!-- the 'database' parameter refers to the database dialect being used.
|
||||||
By default, Hibernate will use a 'HSQL' dialect because 'jpa.database' has been set to 'HSQL'
|
By default, Hibernate will use a 'HSQL' dialect because 'jpa.database' has been set to 'HSQL'
|
||||||
inside file spring/data-access.properties
|
inside file spring/data-access.properties
|
||||||
|
|
||||||
-->
|
-->
|
||||||
</property>
|
</property>
|
||||||
<!-- gDickens: BOTH Persistence Unit and Packages to Scan are NOT compatible, persistenceUnit will win -->
|
<!-- gDickens: BOTH Persistence Unit and Packages to Scan are NOT compatible, persistenceUnit will win -->
|
||||||
|
@ -93,4 +93,4 @@
|
||||||
<beans profile="spring-data-jpa">
|
<beans profile="spring-data-jpa">
|
||||||
<jpa:repositories base-package="org.springframework.samples.petclinic.repository.springdatajpa"/>
|
<jpa:repositories base-package="org.springframework.samples.petclinic.repository.springdatajpa"/>
|
||||||
</beans>
|
</beans>
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<!--
|
<!--
|
||||||
Application context definition for PetClinic Datasource.
|
Application context definition for PetClinic Datasource.
|
||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||||
xmlns:p="http://www.springframework.org/schema/p"
|
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||||
|
xmlns="http://www.springframework.org/schema/beans"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context
|
||||||
|
@ -36,8 +36,8 @@
|
||||||
<jdbc:script location="${jdbc.dataLocation}"/>
|
<jdbc:script location="${jdbc.dataLocation}"/>
|
||||||
</jdbc:initialize-database>
|
</jdbc:initialize-database>
|
||||||
|
|
||||||
<beans profile="javaee" >
|
<beans profile="javaee">
|
||||||
<!-- JNDI DataSource for JEE environments -->
|
<!-- JNDI DataSource for JEE environments -->
|
||||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||||
</beans>
|
</beans>
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<!--
|
<!--
|
||||||
- DispatcherServlet application context for PetClinic's web tier.
|
- DispatcherServlet application context for PetClinic's web tier.
|
||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:p="http://www.springframework.org/schema/p"
|
xmlns:p="http://www.springframework.org/schema/p"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
|
xmlns="http://www.springframework.org/schema/beans"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
||||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
- POJOs labeled with the @Controller and @Service annotations are auto-detected.
|
- POJOs labeled with the @Controller and @Service annotations are auto-detected.
|
||||||
-->
|
-->
|
||||||
<context:component-scan
|
<context:component-scan
|
||||||
base-package="org.springframework.samples.petclinic.web"/>
|
base-package="org.springframework.samples.petclinic.web"/>
|
||||||
|
|
||||||
<mvc:annotation-driven conversion-service="conversionService"/>
|
<mvc:annotation-driven conversion-service="conversionService"/>
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@
|
||||||
<!-- uses WebJars so Javascript and CSS libs can be declared as Maven dependencies (Bootstrap, jQuery...) -->
|
<!-- uses WebJars so Javascript and CSS libs can be declared as Maven dependencies (Bootstrap, jQuery...) -->
|
||||||
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||||
|
|
||||||
<mvc:view-controller path="/" view-name="welcome" />
|
<mvc:view-controller path="/" view-name="welcome"/>
|
||||||
|
|
||||||
<!-- serve static resources (*.html, ...) from src/main/webapp/
|
<!-- serve static resources (*.html, ...) from src/main/webapp/
|
||||||
Required when both servlet-mapping is '/' and static resources need to be served -->
|
Required when both servlet-mapping is '/' and static resources need to be served -->
|
||||||
<mvc:default-servlet-handler />
|
<mvc:default-servlet-handler/>
|
||||||
|
|
||||||
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
|
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
|
||||||
<property name="formatters">
|
<property name="formatters">
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
p:basename="messages/messages"/>
|
p:basename="messages/messages"/>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
- This bean resolves specific types of exceptions to corresponding logical
|
- This bean resolves specific types of exceptions to corresponding logical
|
||||||
- view names for error views.
|
- view names for error views.
|
||||||
-->
|
-->
|
||||||
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
<!--
|
<!--
|
||||||
- DispatcherServlet application context for PetClinic's web tier.
|
- DispatcherServlet application context for PetClinic's web tier.
|
||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
|
||||||
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
|
||||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
<!--
|
<!--
|
||||||
|
@ -13,19 +13,19 @@
|
||||||
- When the media type is 'text/html', it will delegate to the InternalResourceViewResolver's JstlView,
|
- When the media type is 'text/html', it will delegate to the InternalResourceViewResolver's JstlView,
|
||||||
- otherwise to the BeanNameViewResolver.
|
- otherwise to the BeanNameViewResolver.
|
||||||
-->
|
-->
|
||||||
<mvc:view-resolvers>
|
<mvc:view-resolvers>
|
||||||
<mvc:content-negotiation use-not-acceptable="true">
|
<mvc:content-negotiation use-not-acceptable="true">
|
||||||
<mvc:default-views>
|
<mvc:default-views>
|
||||||
<bean class="org.springframework.web.servlet.view.JstlView">
|
<bean class="org.springframework.web.servlet.view.JstlView">
|
||||||
<property name="url" value="" />
|
<property name="url" value=""/>
|
||||||
</bean>
|
</bean>
|
||||||
</mvc:default-views>
|
</mvc:default-views>
|
||||||
</mvc:content-negotiation>
|
</mvc:content-negotiation>
|
||||||
|
|
||||||
<!-- Registering BeanNameViewResolver and InternalViewResolver -->
|
<!-- Registering BeanNameViewResolver and InternalViewResolver -->
|
||||||
<mvc:bean-name />
|
<mvc:bean-name/>
|
||||||
<mvc:jsp prefix="/WEB-INF/jsp/" suffix=".jsp"/>
|
<mvc:jsp prefix="/WEB-INF/jsp/" suffix=".jsp"/>
|
||||||
</mvc:view-resolvers>
|
</mvc:view-resolvers>
|
||||||
|
|
||||||
<!-- Renders an XML view. Used by the BeanNameViewResolver -->
|
<!-- Renders an XML view. Used by the BeanNameViewResolver -->
|
||||||
<bean id="vets/vetList.xml" class="org.springframework.web.servlet.view.xml.MarshallingView">
|
<bean id="vets/vetList.xml" class="org.springframework.web.servlet.view.xml.MarshallingView">
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<!--
|
<!--
|
||||||
Application context definition for PetClinic on JPA.
|
Application context definition for PetClinic on JPA.
|
||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:cache="http://www.springframework.org/schema/cache"
|
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||||
|
xmlns="http://www.springframework.org/schema/beans"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/aop
|
xsi:schemaLocation="http://www.springframework.org/schema/aop
|
||||||
http://www.springframework.org/schema/aop/spring-aop.xsd
|
http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
|
@ -46,4 +46,4 @@
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<li style="width: 160px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i
|
<li style="width: 160px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i
|
||||||
class="icon-th-list"></i> Veterinarians</a></li>
|
class="icon-th-list"></i> Veterinarians</a></li>
|
||||||
<li style="width: 110px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />"
|
<li style="width: 110px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />"
|
||||||
title="trigger a RuntimeException to see how it is handled"><i
|
title="trigger a RuntimeException to see how it is handled"><i
|
||||||
class="icon-warning-sign"></i> Error</a></li>
|
class="icon-warning-sign"></i> Error</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,13 +18,13 @@ PetClinic :: a Spring Framework demonstration
|
||||||
<spring:url value="/webjars/jquery/2.0.3/jquery.js" var="jQuery"/>
|
<spring:url value="/webjars/jquery/2.0.3/jquery.js" var="jQuery"/>
|
||||||
<script src="${jQuery}"></script>
|
<script src="${jQuery}"></script>
|
||||||
|
|
||||||
<!-- jquery-ui.js file is really big so we only load what we need instead of loading everything -->
|
<!-- jquery-ui.js file is really big so we only load what we need instead of loading everything -->
|
||||||
<spring:url value="/webjars/jquery-ui/1.10.3/ui/jquery.ui.core.js" var="jQueryUiCore"/>
|
<spring:url value="/webjars/jquery-ui/1.10.3/ui/jquery.ui.core.js" var="jQueryUiCore"/>
|
||||||
<script src="${jQueryUiCore}"></script>
|
<script src="${jQueryUiCore}"></script>
|
||||||
|
|
||||||
<spring:url value="/webjars/jquery-ui/1.10.3/ui/jquery.ui.datepicker.js" var="jQueryUiDatePicker"/>
|
<spring:url value="/webjars/jquery-ui/1.10.3/ui/jquery.ui.datepicker.js" var="jQueryUiDatePicker"/>
|
||||||
<script src="${jQueryUiDatePicker}"></script>
|
<script src="${jQueryUiDatePicker}"></script>
|
||||||
|
|
||||||
<!-- jquery-ui.css file is not that big so we can afford to load it -->
|
<!-- jquery-ui.css file is not that big so we can afford to load it -->
|
||||||
<spring:url value="/webjars/jquery-ui/1.10.3/themes/base/jquery-ui.css" var="jQueryUiCss"/>
|
<spring:url value="/webjars/jquery-ui/1.10.3/themes/base/jquery-ui.css" var="jQueryUiCss"/>
|
||||||
<link href="${jQueryUiCss}" rel="stylesheet"></link>
|
<link href="${jQueryUiCss}" rel="stylesheet"></link>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
@ -33,17 +33,17 @@
|
||||||
<th>Telephone</th>
|
<th>Telephone</th>
|
||||||
<td><c:out value="${owner.telephone}"/></td>
|
<td><c:out value="${owner.telephone}"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<spring:url value="{ownerId}/edit.html" var="editUrl">
|
<spring:url value="{ownerId}/edit.html" var="editUrl">
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
<spring:param name="ownerId" value="${owner.id}"/>
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(editUrl)}" class="btn btn-info">Edit Owner</a></td>
|
<a href="${fn:escapeXml(editUrl)}" class="btn btn-info">Edit Owner</a></td>
|
||||||
<td>
|
<td>
|
||||||
<spring:url value="{ownerId}/pets/new.html" var="addUrl">
|
<spring:url value="{ownerId}/pets/new.html" var="addUrl">
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
<spring:param name="ownerId" value="${owner.id}"/>
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(addUrl)}" class="btn btn-success">Add New Pet</a></td>
|
<a href="${fn:escapeXml(addUrl)}" class="btn btn-success">Add New Pet</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -77,21 +77,21 @@
|
||||||
</tr>
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
|
||||||
<spring:url value="/owners/{ownerId}/pets/{petId}/edit" var="petUrl">
|
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
|
||||||
<spring:param name="petId" value="${pet.id}"/>
|
|
||||||
</spring:url>
|
|
||||||
<a href="${fn:escapeXml(petUrl)}">Edit Pet</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
|
<spring:url value="/owners/{ownerId}/pets/{petId}/edit" var="petUrl">
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
<spring:param name="ownerId" value="${owner.id}"/>
|
||||||
<spring:param name="petId" value="${pet.id}"/>
|
<spring:param name="petId" value="${pet.id}"/>
|
||||||
</spring:url>
|
</spring:url>
|
||||||
<a href="${fn:escapeXml(visitUrl)}">Add Visit</a>
|
<a href="${fn:escapeXml(petUrl)}">Edit Pet</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td>
|
||||||
|
<spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
|
||||||
|
<spring:param name="ownerId" value="${owner.id}"/>
|
||||||
|
<spring:param name="petId" value="${pet.id}"/>
|
||||||
|
</spring:url>
|
||||||
|
<a href="${fn:escapeXml(visitUrl)}">Add Visit</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
@ -14,8 +14,8 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<jsp:include page="../fragments/bodyHeader.jsp"/>
|
<jsp:include page="../fragments/bodyHeader.jsp"/>
|
||||||
<h2>Owners</h2>
|
<h2>Owners</h2>
|
||||||
|
|
||||||
<datatables:table id="owners" data="${selections}" row="owner" theme="bootstrap2"
|
<datatables:table id="owners" data="${selections}" row="owner" theme="bootstrap2"
|
||||||
cssClass="table table-striped" pageable="false" info="false" export="pdf">
|
cssClass="table table-striped" pageable="false" info="false" export="pdf">
|
||||||
<datatables:column title="Name" cssStyle="width: 150px;" display="html">
|
<datatables:column title="Name" cssStyle="width: 150px;" display="html">
|
||||||
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
|
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
|
||||||
|
@ -34,9 +34,9 @@
|
||||||
<c:out value="${pet.name}"/>
|
<c:out value="${pet.name}"/>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</datatables:column>
|
</datatables:column>
|
||||||
<datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;" />
|
<datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;"/>
|
||||||
</datatables:table>
|
</datatables:table>
|
||||||
|
|
||||||
<jsp:include page="../fragments/footer.jsp"/>
|
<jsp:include page="../fragments/footer.jsp"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$("#birthDate").datepicker({ dateFormat: 'yy/mm/dd'});
|
$("#birthDate").datepicker({dateFormat: 'yy/mm/dd'});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$("#date").datepicker({ dateFormat: 'yy/mm/dd'});
|
$("#date").datepicker({dateFormat: 'yy/mm/dd'});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -42,10 +42,10 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<form:form modelAttribute="visit">
|
<form:form modelAttribute="visit">
|
||||||
|
|
||||||
<petclinic:inputField label="date" name="date" />
|
<petclinic:inputField label="date" name="date"/>
|
||||||
<petclinic:inputField label="description" name="description" />
|
<petclinic:inputField label="description" name="description"/>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="hidden" name="petId" value="${visit.pet.id}"/>
|
<input type="hidden" name="petId" value="${visit.pet.id}"/>
|
||||||
<button type="submit">Add Visit</button>
|
<button type="submit">Add Visit</button>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
<h2>Veterinarians</h2>
|
<h2>Veterinarians</h2>
|
||||||
|
|
||||||
<datatables:table id="vets" data="${vets.vetList}" row="vet" theme="bootstrap2" cssClass="table table-striped" pageable="false" info="false">
|
<datatables:table id="vets" data="${vets.vetList}" row="vet" theme="bootstrap2" cssClass="table table-striped"
|
||||||
|
pageable="false" info="false">
|
||||||
<datatables:column title="Name">
|
<datatables:column title="Name">
|
||||||
<c:out value="${vet.firstName} ${vet.lastName}"></c:out>
|
<c:out value="${vet.firstName} ${vet.lastName}"></c:out>
|
||||||
</datatables:column>
|
</datatables:column>
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
|
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
|
||||||
</datatables:column>
|
</datatables:column>
|
||||||
</datatables:table>
|
</datatables:table>
|
||||||
|
|
||||||
<table class="table-buttons">
|
<table class="table-buttons">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||||
version="3.0" metadata-complete="true">
|
version="3.0" metadata-complete="true">
|
||||||
|
|
||||||
<display-name>Spring PetClinic</display-name>
|
<display-name>Spring PetClinic</display-name>
|
||||||
<description>Spring PetClinic sample application</description>
|
<description>Spring PetClinic sample application</description>
|
||||||
|
|
||||||
<!-- When using Spring jpa, use the following: -->
|
<!-- When using Spring jpa, use the following: -->
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>spring.profiles.active</param-name>
|
<param-name>spring.profiles.active</param-name>
|
||||||
<param-value>jpa</param-value>
|
<param-value>jpa</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<!-- When using Spring JDBC, use the following: -->
|
<!-- When using Spring JDBC, use the following: -->
|
||||||
<!-- <context-param>
|
<!-- <context-param>
|
||||||
<param-name>spring.profiles.active</param-name>
|
<param-name>spring.profiles.active</param-name>
|
||||||
<param-value>jdbc</param-value>
|
<param-value>jdbc</param-value>
|
||||||
</context-param> -->
|
</context-param> -->
|
||||||
|
|
||||||
<!-- the CallMonitoringAspect counts invocations on classes with @Repository on them. Classes in spring-data-jpa don't have that annotation -->
|
<!-- the CallMonitoringAspect counts invocations on classes with @Repository on them. Classes in spring-data-jpa don't have that annotation -->
|
||||||
<!-- When using Spring Data JPA, uncomment the following: -->
|
<!-- When using Spring Data JPA, uncomment the following: -->
|
||||||
<!--
|
<!--
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>spring.profiles.active</param-name>
|
<param-name>spring.profiles.active</param-name>
|
||||||
<param-value>spring-data-jpa</param-value>
|
<param-value>spring-data-jpa</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
- Location of the XML file that defines the root application context.
|
- Location of the XML file that defines the root application context.
|
||||||
|
@ -70,26 +70,26 @@
|
||||||
<servlet-name>dandelionServlet</servlet-name>
|
<servlet-name>dandelionServlet</servlet-name>
|
||||||
<url-pattern>/dandelion-assets/*</url-pattern>
|
<url-pattern>/dandelion-assets/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<!-- used to provide the ability to enter Chinese characters inside the Owner Form -->
|
<!-- used to provide the ability to enter Chinese characters inside the Owner Form -->
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>encodingFilter</filter-name>
|
<filter-name>encodingFilter</filter-name>
|
||||||
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
||||||
<init-param>
|
<init-param>
|
||||||
<param-name>encoding</param-name>
|
<param-name>encoding</param-name>
|
||||||
<param-value>UTF-8</param-value>
|
<param-value>UTF-8</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
<init-param>
|
<init-param>
|
||||||
<param-name>forceEncoding</param-name>
|
<param-name>forceEncoding</param-name>
|
||||||
<param-value>true</param-value>
|
<param-value>true</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
</filter>
|
</filter>
|
||||||
|
|
||||||
<filter-mapping>
|
<filter-mapping>
|
||||||
<filter-name>encodingFilter</filter-name>
|
<filter-name>encodingFilter</filter-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<!-- Dandelion filter definition and mapping -->
|
<!-- Dandelion filter definition and mapping -->
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>dandelionFilter</filter-name>
|
<filter-name>dandelionFilter</filter-name>
|
||||||
|
@ -100,19 +100,19 @@
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<!-- Dandelion-Datatables filter, used for basic export -->
|
<!-- Dandelion-Datatables filter, used for basic export -->
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>datatables</filter-name>
|
<filter-name>datatables</filter-name>
|
||||||
<filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
|
<filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
|
||||||
</filter>
|
</filter>
|
||||||
<filter-mapping>
|
<filter-mapping>
|
||||||
<filter-name>datatables</filter-name>
|
<filter-name>datatables</filter-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<!-- No need for welcome-file declaration here.
|
<!-- No need for welcome-file declaration here.
|
||||||
See inside spring/mvc-core-config.xml :
|
See inside spring/mvc-core-config.xml :
|
||||||
<mvc:view-controller path="/" view-name="welcome" />
|
<mvc:view-controller path="/" view-name="welcome" />
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|
|
@ -13,24 +13,22 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Michael Isvy
|
* @author Michael Isvy
|
||||||
* Simple test to make sure that Bean Validation is working
|
* Simple test to make sure that Bean Validation is working
|
||||||
* (useful when upgrading to a new version of Hibernate Validator/ Bean Validation)
|
* (useful when upgrading to a new version of Hibernate Validator/ Bean Validation)
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ValidatorTests {
|
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() {
|
public void shouldNotValidateWhenFirstNameEmpty() {
|
||||||
|
|
||||||
LocaleContextHolder.setLocale(Locale.ENGLISH);
|
LocaleContextHolder.setLocale(Locale.ENGLISH);
|
||||||
Person person = new Person();
|
Person person = new Person();
|
||||||
person.setFirstName("");
|
person.setFirstName("");
|
||||||
person.setLastName("smith");
|
person.setLastName("smith");
|
||||||
|
@ -39,9 +37,9 @@ public class ValidatorTests {
|
||||||
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person);
|
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person);
|
||||||
|
|
||||||
assertThat(constraintViolations.size()).isEqualTo(1);
|
assertThat(constraintViolations.size()).isEqualTo(1);
|
||||||
ConstraintViolation<Person> violation = constraintViolations.iterator().next();
|
ConstraintViolation<Person> violation = constraintViolations.iterator().next();
|
||||||
assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
|
assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
|
||||||
assertThat(violation.getMessage()).isEqualTo("may not be empty");
|
assertThat(violation.getMessage()).isEqualTo("may not be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,8 @@ public abstract class AbstractClinicServiceTests {
|
||||||
Owner owner = this.clinicService.findOwnerById(1);
|
Owner owner = this.clinicService.findOwnerById(1);
|
||||||
assertThat(owner.getLastName()).startsWith("Franklin");
|
assertThat(owner.getLastName()).startsWith("Franklin");
|
||||||
assertThat(owner.getPets().size()).isEqualTo(1);
|
assertThat(owner.getPets().size()).isEqualTo(1);
|
||||||
assertThat(owner.getPets().get(0).getType()).isNotNull();
|
assertThat(owner.getPets().get(0).getType()).isNotNull();
|
||||||
assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat");
|
assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -78,7 +78,7 @@ public abstract class AbstractClinicServiceTests {
|
||||||
public void shouldInsertOwner() {
|
public void shouldInsertOwner() {
|
||||||
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
|
Collection<Owner> owners = this.clinicService.findOwnerByLastName("Schultz");
|
||||||
int found = owners.size();
|
int found = owners.size();
|
||||||
|
|
||||||
Owner owner = new Owner();
|
Owner owner = new Owner();
|
||||||
owner.setFirstName("Sam");
|
owner.setFirstName("Sam");
|
||||||
owner.setLastName("Schultz");
|
owner.setLastName("Schultz");
|
||||||
|
@ -94,11 +94,11 @@ public abstract class AbstractClinicServiceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public void shouldUpdateOwner() {
|
public void shouldUpdateOwner() {
|
||||||
Owner owner = this.clinicService.findOwnerById(1);
|
Owner owner = this.clinicService.findOwnerById(1);
|
||||||
String oldLastName = owner.getLastName();
|
String oldLastName = owner.getLastName();
|
||||||
String newLastName = oldLastName + "X";
|
String newLastName = oldLastName + "X";
|
||||||
|
|
||||||
owner.setLastName(newLastName);
|
owner.setLastName(newLastName);
|
||||||
this.clinicService.saveOwner(owner);
|
this.clinicService.saveOwner(owner);
|
||||||
|
|
||||||
|
@ -107,87 +107,87 @@ public abstract class AbstractClinicServiceTests {
|
||||||
assertThat(owner.getLastName()).isEqualTo(newLastName);
|
assertThat(owner.getLastName()).isEqualTo(newLastName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldFindPetWithCorrectId() {
|
public void shouldFindPetWithCorrectId() {
|
||||||
Pet pet7 = this.clinicService.findPetById(7);
|
Pet pet7 = this.clinicService.findPetById(7);
|
||||||
assertThat(pet7.getName()).startsWith("Samantha");
|
assertThat(pet7.getName()).startsWith("Samantha");
|
||||||
assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean");
|
assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
}
|
||||||
public void shouldFindAllPetTypes() {
|
|
||||||
Collection<PetType> 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
|
@Test
|
||||||
@Transactional
|
public void shouldFindAllPetTypes() {
|
||||||
public void shouldInsertPetIntoDatabaseAndGenerateId() {
|
Collection<PetType> petTypes = this.clinicService.findPetTypes();
|
||||||
Owner owner6 = this.clinicService.findOwnerById(6);
|
|
||||||
int found = owner6.getPets().size();
|
|
||||||
|
|
||||||
Pet pet = new Pet();
|
|
||||||
pet.setName("bowser");
|
|
||||||
Collection<PetType> 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
|
PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
|
||||||
@Transactional
|
assertThat(petType1.getName()).isEqualTo("cat");
|
||||||
public void shouldUpdatePetName() throws Exception {
|
PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
|
||||||
Pet pet7 = this.clinicService.findPetById(7);
|
assertThat(petType4.getName()).isEqualTo("snake");
|
||||||
String oldName = pet7.getName();
|
}
|
||||||
|
|
||||||
String newName = oldName + "X";
|
|
||||||
pet7.setName(newName);
|
|
||||||
this.clinicService.savePet(pet7);
|
|
||||||
|
|
||||||
pet7 = this.clinicService.findPetById(7);
|
@Test
|
||||||
assertThat(pet7.getName()).isEqualTo(newName);
|
@Transactional
|
||||||
}
|
public void shouldInsertPetIntoDatabaseAndGenerateId() {
|
||||||
|
Owner owner6 = this.clinicService.findOwnerById(6);
|
||||||
|
int found = owner6.getPets().size();
|
||||||
|
|
||||||
@Test
|
Pet pet = new Pet();
|
||||||
public void shouldFindVets() {
|
pet.setName("bowser");
|
||||||
Collection<Vet> vets = this.clinicService.findVets();
|
Collection<PetType> types = this.clinicService.findPetTypes();
|
||||||
|
pet.setType(EntityUtils.getById(types, PetType.class, 2));
|
||||||
Vet vet = EntityUtils.getById(vets, Vet.class, 3);
|
pet.setBirthDate(new DateTime());
|
||||||
assertThat(vet.getLastName()).isEqualTo("Douglas");
|
owner6.addPet(pet);
|
||||||
assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
|
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
|
||||||
assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry");
|
|
||||||
assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
this.clinicService.savePet(pet);
|
||||||
@Transactional
|
this.clinicService.saveOwner(owner6);
|
||||||
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);
|
owner6 = this.clinicService.findOwnerById(6);
|
||||||
assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
|
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
|
||||||
assertThat(visit.getId()).isNotNull();
|
// 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<Vet> 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,11 @@ import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Integration test using the jdbc profile.
|
* <p> Integration test using the jdbc profile.
|
||||||
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
|
||||||
*
|
*
|
||||||
* @author Thomas Risberg
|
* @author Thomas Risberg
|
||||||
* @author Michael Isvy
|
* @author Michael Isvy
|
||||||
|
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
||||||
*/
|
*/
|
||||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package org.springframework.samples.petclinic.service;
|
package org.springframework.samples.petclinic.service;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -7,12 +6,12 @@ import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Integration test using the jpa profile.
|
* <p> Integration test using the jpa profile.
|
||||||
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @author Michael Isvy
|
* @author Michael Isvy
|
||||||
|
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||||
|
@ -20,4 +19,4 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
@ActiveProfiles("jpa")
|
@ActiveProfiles("jpa")
|
||||||
public class ClinicServiceJpaTests extends AbstractClinicServiceTests {
|
public class ClinicServiceJpaTests extends AbstractClinicServiceTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package org.springframework.samples.petclinic.service;
|
package org.springframework.samples.petclinic.service;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -7,9 +6,10 @@ import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Integration test using the 'Spring Data' profile.
|
* <p> Integration test using the 'Spring Data' profile.
|
||||||
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
*
|
||||||
* @author Michael Isvy
|
* @author Michael Isvy
|
||||||
|
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||||
|
@ -17,4 +17,4 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
@ActiveProfiles("spring-data-jpa")
|
@ActiveProfiles("spring-data-jpa")
|
||||||
public class ClinicServiceSpringDataJpaTests extends AbstractClinicServiceTests {
|
public class ClinicServiceSpringDataJpaTests extends AbstractClinicServiceTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ public class VetControllerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetExistingUser() throws Exception {
|
public void testGetExistingUser() throws Exception {
|
||||||
ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON))
|
ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
actions.andExpect(content().contentType("application/json;charset=UTF-8"))
|
actions.andExpect(content().contentType("application/json;charset=UTF-8"))
|
||||||
.andExpect(jsonPath("$.vetList[0].id").value(1));
|
.andExpect(jsonPath("$.vetList[0].id").value(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue