mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Merge branch 'master' into javaconfig
Conflicts: src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java src/main/resources/spring/data-access.properties
This commit is contained in:
commit
7961e44714
17 changed files with 179 additions and 224 deletions
100
pom.xml
100
pom.xml
|
@ -17,7 +17,7 @@
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<spring-io-platform.version>2.0.7.RELEASE</spring-io-platform.version>
|
<spring-io-platform.version>2.0.8.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>
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,20 +27,17 @@
|
||||||
<!-- 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>
|
|
||||||
|
|
||||||
<!-- Others -->
|
<!-- Others -->
|
||||||
<mysql-driver.version>5.1.36</mysql-driver.version>
|
<mysql-driver.version>5.1.36</mysql-driver.version>
|
||||||
|
|
||||||
<!-- Web dependencies -->
|
|
||||||
<dandelion.version>1.1.1</dandelion.version>
|
|
||||||
<dandelion.datatables.version>1.1.0</dandelion.datatables.version>
|
|
||||||
|
|
||||||
<cobertura.version>2.7</cobertura.version>
|
<cobertura.version>2.7</cobertura.version>
|
||||||
|
|
||||||
|
<jpa.database>HSQL</jpa.database>
|
||||||
|
<jdbc.driverClassName>org.hsqldb.jdbcDriver</jdbc.driverClassName>
|
||||||
|
<jdbc.url>jdbc:hsqldb:mem:petclinic</jdbc.url>
|
||||||
|
<jdbc.username>sa</jdbc.username>
|
||||||
|
<jdbc.password></jdbc.password>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -57,11 +54,6 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jadira.usertype</groupId>
|
|
||||||
<artifactId>usertype.core</artifactId>
|
|
||||||
<version>${jadira-usertype-core.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat</groupId>
|
<groupId>org.apache.tomcat</groupId>
|
||||||
<artifactId>tomcat-servlet-api</artifactId>
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
|
@ -89,6 +81,14 @@
|
||||||
<artifactId>taglibs-standard-jstlel</artifactId>
|
<artifactId>taglibs-standard-jstlel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- JSon -->
|
<!-- JSon -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
|
@ -161,22 +161,6 @@
|
||||||
<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 -->
|
<!-- Databases - Uses HSQL by default -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hsqldb</groupId>
|
<groupId>org.hsqldb</groupId>
|
||||||
|
@ -184,13 +168,6 @@
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- For MySql only -->
|
|
||||||
<!--dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<version>${mysql-driver.version}</version>
|
|
||||||
</dependency-->
|
|
||||||
|
|
||||||
<!-- HIBERNATE -->
|
<!-- HIBERNATE -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
|
@ -244,22 +221,6 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Dandelion -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dandelion</groupId>
|
|
||||||
<artifactId>dandelion-jsp</artifactId>
|
|
||||||
<version>${dandelion.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dandelion</groupId>
|
|
||||||
<artifactId>datatables-jsp</artifactId>
|
|
||||||
<version>${dandelion.datatables.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dandelion</groupId>
|
|
||||||
<artifactId>datatables-export-itext</artifactId>
|
|
||||||
<version>${dandelion.datatables.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- temporary fix: below dependency should not be necessary as it is a transitive 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 -->
|
For some reason we can't build the app unless it is a first level dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -272,6 +233,12 @@
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>install</defaultGoal>
|
<defaultGoal>install</defaultGoal>
|
||||||
<finalName>petclinic</finalName>
|
<finalName>petclinic</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${basedir}/src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<testResources>
|
<testResources>
|
||||||
<testResource>
|
<testResource>
|
||||||
<!-- declared explicitly so Spring config files can be placed next to their corresponding JUnit test class -->
|
<!-- declared explicitly so Spring config files can be placed next to their corresponding JUnit test class -->
|
||||||
|
@ -376,6 +343,14 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<!--Specify the encoding for copying resources-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<reporting>
|
<reporting>
|
||||||
|
@ -450,6 +425,23 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>MYSQL</id>
|
||||||
|
<properties>
|
||||||
|
<jpa.database>MYSQL</jpa.database>
|
||||||
|
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
|
||||||
|
<jdbc.url>jdbc:mysql://localhost:3306/petclinic?useUnicode=true</jdbc.url>
|
||||||
|
<jdbc.username>root</jdbc.username>
|
||||||
|
<jdbc.password>petclinic</jdbc.password>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>${mysql-driver.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<url>demopetclinic</url>
|
<url>demopetclinic</url>
|
||||||
|
|
27
readme.md
27
readme.md
|
@ -20,7 +20,23 @@ Our issue tracker is available here: https://github.com/spring-projects/spring-p
|
||||||
|
|
||||||
In its default configuration, Petclinic uses an in-memory database (HSQLDB) which
|
In its default configuration, Petclinic uses an in-memory database (HSQLDB) which
|
||||||
gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed.
|
gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed.
|
||||||
Note that whenever the database type is changed, the data-access.properties file needs to be updated and the mysql-connector-java artifact from the pom.xml needs to be uncommented.
|
To run petclinic locally using MySQL database, it is needed to run with 'MYSQL' profile defined in main pom.xml file.
|
||||||
|
|
||||||
|
```
|
||||||
|
./mvnw tomcat7:run -P MYSQL
|
||||||
|
```
|
||||||
|
|
||||||
|
Before do this, would be good to check properties defined in MYSQL profile inside pom.xml file.
|
||||||
|
|
||||||
|
```
|
||||||
|
<properties>
|
||||||
|
<jpa.database>MYSQL</jpa.database>
|
||||||
|
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
|
||||||
|
<jdbc.url>jdbc:mysql://localhost:3306/petclinic?useUnicode=true</jdbc.url>
|
||||||
|
<jdbc.username>root</jdbc.username>
|
||||||
|
<jdbc.password>petclinic</jdbc.password>
|
||||||
|
</properties>
|
||||||
|
```
|
||||||
|
|
||||||
You may start a MySql database with docker:
|
You may start a MySql database with docker:
|
||||||
|
|
||||||
|
@ -91,15 +107,6 @@ File -> Import -> Maven -> Existing Maven project
|
||||||
<a href="/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp#L12">sample usage in JSP</a></td>
|
<a href="/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp#L12">sample usage in JSP</a></td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>Dandelion-datatables</td>
|
|
||||||
<td>
|
|
||||||
<a href="/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp">ownersList.jsp</a>
|
|
||||||
<a href="/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp">vetList.jsp</a>
|
|
||||||
<a href="/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java">PetclinicInitializer.java</a>
|
|
||||||
<a href="/src/main/resources/dandelion/datatables/datatables.properties">datatables.properties</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Thymeleaf branch</td>
|
<td>Thymeleaf branch</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic;
|
package org.springframework.samples.petclinic;
|
||||||
|
|
||||||
import com.github.dandelion.core.web.DandelionFilter;
|
|
||||||
import com.github.dandelion.core.web.DandelionServlet;
|
|
||||||
import com.github.dandelion.datatables.core.web.filter.DatatablesFilter;
|
|
||||||
import org.springframework.samples.petclinic.config.MvcCoreConfig;
|
import org.springframework.samples.petclinic.config.MvcCoreConfig;
|
||||||
import org.springframework.samples.petclinic.config.RootApplicationContextConfig;
|
import org.springframework.samples.petclinic.config.RootApplicationContextConfig;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
@ -26,8 +23,8 @@ import org.springframework.web.filter.CharacterEncodingFilter;
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
|
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.Filter;
|
||||||
import java.util.EnumSet;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,8 +32,8 @@ import java.util.EnumSet;
|
||||||
* {@link ServletContext} programmatically.
|
* {@link ServletContext} programmatically.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Create the Spring "<strong>root</strong>" application context.<br/>
|
* Create the Spring "<strong>root</strong>" application context.<br/>
|
||||||
* Register a {@link DispatcherServlet} and a {@link DandelionServlet} in the servlet context.<br/>
|
* Register a {@link DispatcherServlet} in the servlet context.<br/>
|
||||||
* For both servlets, register a {@link CharacterEncodingFilter}, a {@link DandelionFilter} an a {@link DatatablesFilter}.
|
* For both servlets, register a {@link CharacterEncodingFilter}.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Antoine Rey
|
* @author Antoine Rey
|
||||||
|
@ -52,14 +49,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
|
||||||
*/
|
*/
|
||||||
private static final String SPRING_PROFILE = "jpa";
|
private static final String SPRING_PROFILE = "jpa";
|
||||||
|
|
||||||
private static final String DANDELION_SERVLET = "dandelionServlet";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
|
||||||
super.onStartup(servletContext);
|
|
||||||
registerDandelionServlet(servletContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WebApplicationContext createRootApplicationContext() {
|
protected WebApplicationContext createRootApplicationContext() {
|
||||||
AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
|
AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
|
||||||
|
@ -68,7 +57,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
|
||||||
return rootAppContext;
|
return rootAppContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WebApplicationContext createServletApplicationContext() {
|
protected WebApplicationContext createServletApplicationContext() {
|
||||||
AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
|
AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
|
||||||
|
@ -85,27 +73,7 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
|
||||||
protected Filter[] getServletFilters() {
|
protected Filter[] getServletFilters() {
|
||||||
// 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
|
||||||
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true);
|
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true);
|
||||||
|
return new Filter[]{characterEncodingFilter};
|
||||||
// Dandelion filter definition and mapping -->
|
|
||||||
DandelionFilter dandelionFilter = new DandelionFilter();
|
|
||||||
|
|
||||||
// Dandelion-Datatables filter, used for basic export -->
|
|
||||||
DatatablesFilter datatablesFilter = new DatatablesFilter();
|
|
||||||
|
|
||||||
return new Filter[]{characterEncodingFilter, dandelionFilter, datatablesFilter};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected FilterRegistration.Dynamic registerServletFilter(ServletContext servletContext, Filter filter) {
|
|
||||||
FilterRegistration.Dynamic registration = super.registerServletFilter(servletContext, filter);
|
|
||||||
registration.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE), false, DANDELION_SERVLET);
|
|
||||||
return registration;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerDandelionServlet(ServletContext servletContext) {
|
|
||||||
DandelionServlet dandelionServlet = new DandelionServlet();
|
|
||||||
ServletRegistration.Dynamic registration = servletContext.addServlet(DANDELION_SERVLET, dandelionServlet);
|
|
||||||
registration.setLoadOnStartup(2);
|
|
||||||
registration.addMapping("/dandelion-assets/*");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.model;
|
package org.springframework.samples.petclinic.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import org.springframework.beans.support.MutableSortDefinition;
|
||||||
import java.util.Collections;
|
import org.springframework.beans.support.PropertyComparator;
|
||||||
import java.util.HashSet;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -30,12 +28,14 @@ import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Type;
|
import javax.persistence.Temporal;
|
||||||
import org.joda.time.DateTime;
|
import javax.persistence.TemporalType;
|
||||||
import org.joda.time.LocalDate;
|
import java.util.ArrayList;
|
||||||
import org.springframework.beans.support.MutableSortDefinition;
|
import java.util.Collections;
|
||||||
import org.springframework.beans.support.PropertyComparator;
|
import java.util.Date;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple business object representing a pet.
|
* Simple business object representing a pet.
|
||||||
|
@ -49,9 +49,9 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||||
public class Pet extends NamedEntity {
|
public class Pet extends NamedEntity {
|
||||||
|
|
||||||
@Column(name = "birth_date")
|
@Column(name = "birth_date")
|
||||||
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
|
@Temporal(TemporalType.DATE)
|
||||||
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
||||||
private LocalDate birthDate;
|
private Date birthDate;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "type_id")
|
@JoinColumn(name = "type_id")
|
||||||
|
@ -64,12 +64,13 @@ 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 LocalDate getBirthDate() {
|
|
||||||
return this.birthDate;
|
public void setBirthDate(Date birthDate) {
|
||||||
|
this.birthDate = birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBirthDate(LocalDate birthDate) {
|
public Date getBirthDate() {
|
||||||
this.birthDate = birthDate;
|
return this.birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PetType getType() {
|
public PetType getType() {
|
||||||
|
|
|
@ -15,16 +15,17 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.model;
|
package org.springframework.samples.petclinic.model;
|
||||||
|
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
import org.hibernate.annotations.Type;
|
import javax.persistence.TemporalType;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import java.util.Date;
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple JavaBean domain object representing a visit.
|
* Simple JavaBean domain object representing a visit.
|
||||||
|
@ -39,9 +40,9 @@ public class Visit extends BaseEntity {
|
||||||
* Holds value of property date.
|
* Holds value of property date.
|
||||||
*/
|
*/
|
||||||
@Column(name = "visit_date")
|
@Column(name = "visit_date")
|
||||||
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
||||||
private LocalDate date;
|
private Date date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds value of property description.
|
* Holds value of property description.
|
||||||
|
@ -62,7 +63,7 @@ public class Visit extends BaseEntity {
|
||||||
* Creates a new instance of Visit for the current date
|
* Creates a new instance of Visit for the current date
|
||||||
*/
|
*/
|
||||||
public Visit() {
|
public Visit() {
|
||||||
this.date = new LocalDate();
|
this.date = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ public class Visit extends BaseEntity {
|
||||||
*
|
*
|
||||||
* @return Value of property date.
|
* @return Value of property date.
|
||||||
*/
|
*/
|
||||||
public LocalDate getDate() {
|
public Date getDate() {
|
||||||
return this.date;
|
return this.date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ public class Visit extends BaseEntity {
|
||||||
*
|
*
|
||||||
* @param date New value of property date.
|
* @param date New value of property date.
|
||||||
*/
|
*/
|
||||||
public void setDate(LocalDate date) {
|
public void setDate(Date date) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.springframework.orm.ObjectRetrievalFailureException;
|
||||||
import org.springframework.samples.petclinic.model.Owner;
|
import org.springframework.samples.petclinic.model.Owner;
|
||||||
import org.springframework.samples.petclinic.model.Pet;
|
import org.springframework.samples.petclinic.model.Pet;
|
||||||
import org.springframework.samples.petclinic.model.PetType;
|
import org.springframework.samples.petclinic.model.PetType;
|
||||||
import org.springframework.samples.petclinic.model.Visit;
|
|
||||||
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
import org.springframework.samples.petclinic.repository.OwnerRepository;
|
||||||
import org.springframework.samples.petclinic.repository.PetRepository;
|
import org.springframework.samples.petclinic.repository.PetRepository;
|
||||||
import org.springframework.samples.petclinic.repository.VisitRepository;
|
import org.springframework.samples.petclinic.repository.VisitRepository;
|
||||||
|
@ -115,7 +114,7 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
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())
|
||||||
.addValue("type_id", pet.getType().getId())
|
.addValue("type_id", pet.getType().getId())
|
||||||
.addValue("owner_id", pet.getOwner().getId());
|
.addValue("owner_id", pet.getOwner().getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +33,7 @@ class JdbcPetRowMapper implements RowMapper<JdbcPet> {
|
||||||
pet.setId(rs.getInt("pets.id"));
|
pet.setId(rs.getInt("pets.id"));
|
||||||
pet.setName(rs.getString("name"));
|
pet.setName(rs.getString("name"));
|
||||||
Date birthDate = rs.getDate("birth_date");
|
Date birthDate = rs.getDate("birth_date");
|
||||||
pet.setBirthDate(new LocalDate(birthDate));
|
pet.setBirthDate(new Date(birthDate.getTime()));
|
||||||
pet.setTypeId(rs.getInt("type_id"));
|
pet.setTypeId(rs.getInt("type_id"));
|
||||||
pet.setOwnerId(rs.getInt("owner_id"));
|
pet.setOwnerId(rs.getInt("owner_id"));
|
||||||
return pet;
|
return pet;
|
||||||
|
|
|
@ -17,7 +17,6 @@ package org.springframework.samples.petclinic.repository.jdbc;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
||||||
|
@ -77,7 +76,7 @@ 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())
|
||||||
.addValue("description", visit.getDescription())
|
.addValue("description", visit.getDescription())
|
||||||
.addValue("pet_id", visit.getPet().getId());
|
.addValue("pet_id", visit.getPet().getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
package org.springframework.samples.petclinic.repository.jdbc;
|
package org.springframework.samples.petclinic.repository.jdbc;
|
||||||
|
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.samples.petclinic.model.Visit;
|
import org.springframework.samples.petclinic.model.Visit;
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ class JdbcVisitRowMapper implements RowMapper<Visit> {
|
||||||
Visit visit = new Visit();
|
Visit visit = new Visit();
|
||||||
visit.setId(rs.getInt("visit_id"));
|
visit.setId(rs.getInt("visit_id"));
|
||||||
Date visitDate = rs.getDate("visit_date");
|
Date visitDate = rs.getDate("visit_date");
|
||||||
visit.setDate(new LocalDate(visitDate));
|
visit.setDate(new Date(visitDate.getTime()));
|
||||||
visit.setDescription(rs.getString("description"));
|
visit.setDescription(rs.getString("description"));
|
||||||
return visit;
|
return visit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,16 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.repository.jpa;
|
package org.springframework.samples.petclinic.repository.jpa;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.persistence.PersistenceContext;
|
|
||||||
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.samples.petclinic.model.Vet;
|
import org.springframework.samples.petclinic.model.Vet;
|
||||||
import org.springframework.samples.petclinic.repository.VetRepository;
|
import org.springframework.samples.petclinic.repository.VetRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JPA implementation of the {@link VetRepository} interface.
|
* JPA implementation of the {@link VetRepository} interface.
|
||||||
*
|
*
|
||||||
|
@ -42,7 +40,6 @@ public class JpaVetRepositoryImpl implements VetRepository {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "vets")
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Collection<Vet> findAll() {
|
public Collection<Vet> findAll() {
|
||||||
return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
|
return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
# ==================================
|
|
||||||
# Dandelion-Datatables configuration
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
# Disable the asset management of Dandelion-Core for all non-DataTable-related assets
|
|
||||||
main.standalone=true
|
|
|
@ -4,38 +4,16 @@
|
||||||
# various application context XML files (e.g., "applicationContext-*.xml").
|
# various application context XML files (e.g., "applicationContext-*.xml").
|
||||||
# Targeted at system administrators, to avoid touching the context XML files.
|
# Targeted at system administrators, to avoid touching the context XML files.
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# HSQL Settings
|
|
||||||
|
|
||||||
jdbc.driverClassName=org.hsqldb.jdbcDriver
|
|
||||||
jdbc.url=jdbc:hsqldb:mem:petclinic
|
|
||||||
jdbc.username=sa
|
|
||||||
jdbc.password=
|
|
||||||
|
|
||||||
# Properties that control the population of schema and data for a new data source
|
# Properties that control the population of schema and data for a new data source
|
||||||
jdbc.initLocation=db/hsqldb/initDB.sql
|
jdbc.initLocation=db/hsqldb/initDB.sql
|
||||||
jdbc.dataLocation=db/hsqldb/populateDB.sql
|
jdbc.dataLocation=db/hsqldb/populateDB.sql
|
||||||
|
|
||||||
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
|
||||||
jpa.database=HSQL
|
|
||||||
|
|
||||||
jpa.showSql=true
|
jpa.showSql=true
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
jdbc.driverClassName=${jdbc.driverClassName}
|
||||||
# MySQL Settings
|
jdbc.url=${jdbc.url}
|
||||||
|
jdbc.username=${jdbc.username}
|
||||||
#jdbc.driverClassName=com.mysql.jdbc.Driver
|
jdbc.password=${jdbc.password}
|
||||||
#jdbc.url=jdbc:mysql://localhost:3306/petclinic
|
|
||||||
#jdbc.username=root
|
|
||||||
#jdbc.password=
|
|
||||||
|
|
||||||
# Properties that control the population of schema and data for a new data source
|
|
||||||
#jdbc.initLocation=classpath:db/mysql/initDB.sql
|
|
||||||
#jdbc.dataLocation=classpath:db/mysql/populateDB.sql
|
|
||||||
|
|
||||||
# Property that determines which Hibernate dialect to use
|
|
||||||
# (only applied with "applicationContext-hibernate.xml")
|
|
||||||
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
|
||||||
|
|
||||||
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
||||||
#jpa.database=MYSQL
|
jpa.database=${jpa.database}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
|
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<petclinic:layout pageName="owners">
|
<petclinic:layout pageName="owners">
|
||||||
|
@ -54,7 +53,7 @@
|
||||||
<dt>Name</dt>
|
<dt>Name</dt>
|
||||||
<dd><c:out value="${pet.name}"/></dd>
|
<dd><c:out value="${pet.name}"/></dd>
|
||||||
<dt>Birth Date</dt>
|
<dt>Birth Date</dt>
|
||||||
<dd><joda:format value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
|
<dd><fmt:formatDate value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
|
||||||
<dt>Type</dt>
|
<dt>Type</dt>
|
||||||
<dd><c:out value="${pet.type.name}"/></dd>
|
<dd><c:out value="${pet.type.name}"/></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
@ -69,7 +68,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<c:forEach var="visit" items="${pet.visits}">
|
<c:forEach var="visit" items="${pet.visits}">
|
||||||
<tr>
|
<tr>
|
||||||
<td><joda:format value="${visit.date}" pattern="yyyy-MM-dd"/></td>
|
<td><fmt:formatDate value="${visit.date}" pattern="yyyy-MM-dd"/></td>
|
||||||
<td><c:out value="${visit.description}"/></td>
|
<td><c:out value="${visit.description}"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
|
|
|
@ -3,31 +3,46 @@
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
|
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<petclinic:layout pageName="owners">
|
<petclinic:layout pageName="owners">
|
||||||
<h2>Owners</h2>
|
<h2>Owners</h2>
|
||||||
|
|
||||||
<datatables:table id="owners" data="${selections}" row="owner"
|
<table id="vets" class="table table-striped">
|
||||||
cssClass="table table-striped" pageable="false" info="false" export="pdf">
|
<thead>
|
||||||
<datatables:column title="Name" cssStyle="width: 150px;" display="html">
|
<tr>
|
||||||
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
|
<th style="width: 150px;">Name</th>
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
<th style="width: 200px;">Address</th>
|
||||||
</spring:url>
|
<th>City</th>
|
||||||
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
|
<th style="width: 120px">Telephone</th>
|
||||||
</datatables:column>
|
<th>Pets</th>
|
||||||
<datatables:column title="Name" display="pdf">
|
</tr>
|
||||||
<c:out value="${owner.firstName} ${owner.lastName}"/>
|
</thead>
|
||||||
</datatables:column>
|
<tbody>
|
||||||
<datatables:column title="Address" property="address" cssStyle="width: 200px;"/>
|
<c:forEach items="${selections}" var="owner">
|
||||||
<datatables:column title="City" property="city"/>
|
<tr>
|
||||||
<datatables:column title="Telephone" property="telephone"/>
|
<td>
|
||||||
<datatables:column title="Pets" cssStyle="width: 100px;">
|
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
|
||||||
<c:forEach var="pet" items="${owner.pets}">
|
<spring:param name="ownerId" value="${owner.id}"/>
|
||||||
<c:out value="${pet.name}"/>
|
</spring:url>
|
||||||
</c:forEach>
|
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
|
||||||
</datatables:column>
|
</td>
|
||||||
<datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;"/>
|
<td>
|
||||||
</datatables:table>
|
<c:out value="${owner.address}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${owner.city}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${owner.telephone}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:forEach var="pet" items="${owner.pets}">
|
||||||
|
<c:out value="${pet.name} "/>
|
||||||
|
</c:forEach>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</petclinic:layout>
|
</petclinic:layout>
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
|
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td><c:out value="${visit.pet.name}"/></td>
|
<td><c:out value="${visit.pet.name}"/></td>
|
||||||
<td><joda:format value="${visit.pet.birthDate}" pattern="yyyy/MM/dd"/></td>
|
<td><fmt:formatDate value="${visit.pet.birthDate}" pattern="yyyy/MM/dd"/></td>
|
||||||
<td><c:out value="${visit.pet.type.name}"/></td>
|
<td><c:out value="${visit.pet.type.name}"/></td>
|
||||||
<td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td>
|
<td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -60,7 +59,7 @@
|
||||||
<c:forEach var="visit" items="${visit.pet.visits}">
|
<c:forEach var="visit" items="${visit.pet.visits}">
|
||||||
<c:if test="${!visit['new']}">
|
<c:if test="${!visit['new']}">
|
||||||
<tr>
|
<tr>
|
||||||
<td><joda:format value="${visit.date}" pattern="yyyy/MM/dd"/></td>
|
<td><fmt:formatDate value="${visit.date}" pattern="yyyy/MM/dd"/></td>
|
||||||
<td><c:out value="${visit.description}"/></td>
|
<td><c:out value="${visit.description}"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
|
@ -2,24 +2,34 @@
|
||||||
<%@ 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" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
|
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<petclinic:layout pageName="vets">
|
<petclinic:layout pageName="vets">
|
||||||
<h2>Veterinarians</h2>
|
<h2>Veterinarians</h2>
|
||||||
|
|
||||||
<datatables:table id="vets" data="${vets.vetList}" row="vet" cssClass="table table-striped"
|
<table id="vets" class="table table-striped">
|
||||||
pageable="false" info="false">
|
<thead>
|
||||||
<datatables:column title="Name">
|
<tr>
|
||||||
<c:out value="${vet.firstName} ${vet.lastName}"/>
|
<th>Name</th>
|
||||||
</datatables:column>
|
<th>Specialties</th>
|
||||||
<datatables:column title="Specialties">
|
</tr>
|
||||||
<c:forEach var="specialty" items="${vet.specialties}">
|
</thead>
|
||||||
<c:out value="${specialty.name}"/>
|
<tbody>
|
||||||
</c:forEach>
|
<c:forEach items="${vets.vetList}" var="vet">
|
||||||
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
|
<tr>
|
||||||
</datatables:column>
|
<td>
|
||||||
</datatables:table>
|
<c:out value="${vet.firstName} ${vet.lastName}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:forEach var="specialty" items="${vet.specialties}">
|
||||||
|
<c:out value="${specialty.name} "/>
|
||||||
|
</c:forEach>
|
||||||
|
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<table class="table-buttons">
|
<table class="table-buttons">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -18,9 +18,8 @@ package org.springframework.samples.petclinic.service;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.samples.petclinic.model.Owner;
|
import org.springframework.samples.petclinic.model.Owner;
|
||||||
|
@ -136,7 +135,7 @@ public abstract class AbstractClinicServiceTests {
|
||||||
pet.setName("bowser");
|
pet.setName("bowser");
|
||||||
Collection<PetType> types = this.clinicService.findPetTypes();
|
Collection<PetType> types = this.clinicService.findPetTypes();
|
||||||
pet.setType(EntityUtils.getById(types, PetType.class, 2));
|
pet.setType(EntityUtils.getById(types, PetType.class, 2));
|
||||||
pet.setBirthDate(new LocalDate());
|
pet.setBirthDate(new Date());
|
||||||
owner6.addPet(pet);
|
owner6.addPet(pet);
|
||||||
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
|
assertThat(owner6.getPets().size()).isEqualTo(found + 1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue