Thymeleaf branch |
diff --git a/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java b/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java
index 75d3e6320..653f11ad5 100644
--- a/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java
+++ b/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java
@@ -15,9 +15,6 @@
*/
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.RootApplicationContextConfig;
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.support.AbstractDispatcherServletInitializer;
-import javax.servlet.*;
-import java.util.EnumSet;
+import javax.servlet.Filter;
+import javax.servlet.ServletContext;
/**
@@ -35,8 +32,8 @@ import java.util.EnumSet;
* {@link ServletContext} programmatically.
*
* Create the Spring "root" application context.
- * Register a {@link DispatcherServlet} and a {@link DandelionServlet} in the servlet context.
- * For both servlets, register a {@link CharacterEncodingFilter}, a {@link DandelionFilter} an a {@link DatatablesFilter}.
+ * Register a {@link DispatcherServlet} in the servlet context.
+ * For both servlets, register a {@link CharacterEncodingFilter}.
*
*
* @author Antoine Rey
@@ -52,14 +49,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
*/
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
protected WebApplicationContext createRootApplicationContext() {
AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
@@ -68,7 +57,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
return rootAppContext;
}
-
@Override
protected WebApplicationContext createServletApplicationContext() {
AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
@@ -85,27 +73,7 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
protected Filter[] getServletFilters() {
// Used to provide the ability to enter Chinese characters inside the Owner Form
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true);
-
- // 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};
+ return new Filter[]{characterEncodingFilter};
}
- @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/*");
- }
}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Pet.java b/src/main/java/org/springframework/samples/petclinic/model/Pet.java
index 970cdcb76..0cbf975fa 100644
--- a/src/main/java/org/springframework/samples/petclinic/model/Pet.java
+++ b/src/main/java/org/springframework/samples/petclinic/model/Pet.java
@@ -15,11 +15,9 @@
*/
package org.springframework.samples.petclinic.model;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -30,12 +28,14 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-import org.hibernate.annotations.Type;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.springframework.beans.support.MutableSortDefinition;
-import org.springframework.beans.support.PropertyComparator;
-import org.springframework.format.annotation.DateTimeFormat;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* Simple business object representing a pet.
@@ -49,9 +49,9 @@ import org.springframework.format.annotation.DateTimeFormat;
public class Pet extends NamedEntity {
@Column(name = "birth_date")
- @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
+ @Temporal(TemporalType.DATE)
@DateTimeFormat(pattern = "yyyy/MM/dd")
- private LocalDate birthDate;
+ private Date birthDate;
@ManyToOne
@JoinColumn(name = "type_id")
@@ -64,12 +64,13 @@ public class Pet extends NamedEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
private Set visits;
- public LocalDate getBirthDate() {
- return this.birthDate;
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
}
- public void setBirthDate(LocalDate birthDate) {
- this.birthDate = birthDate;
+ public Date getBirthDate() {
+ return this.birthDate;
}
public PetType getType() {
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Visit.java b/src/main/java/org/springframework/samples/petclinic/model/Visit.java
index 023a8dcef..8fe9deb75 100644
--- a/src/main/java/org/springframework/samples/petclinic/model/Visit.java
+++ b/src/main/java/org/springframework/samples/petclinic/model/Visit.java
@@ -15,16 +15,17 @@
*/
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.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-
-import org.hibernate.annotations.Type;
-import org.hibernate.validator.constraints.NotEmpty;
-import org.joda.time.LocalDate;
-import org.springframework.format.annotation.DateTimeFormat;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import java.util.Date;
/**
* Simple JavaBean domain object representing a visit.
@@ -39,9 +40,9 @@ public class Visit extends BaseEntity {
* Holds value of property date.
*/
@Column(name = "visit_date")
- @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
+ @Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(pattern = "yyyy/MM/dd")
- private LocalDate date;
+ private Date date;
/**
* Holds value of property description.
@@ -62,7 +63,7 @@ public class Visit extends BaseEntity {
* Creates a new instance of Visit for the current date
*/
public Visit() {
- this.date = new LocalDate();
+ this.date = new Date();
}
@@ -71,7 +72,7 @@ public class Visit extends BaseEntity {
*
* @return Value of property date.
*/
- public LocalDate getDate() {
+ public Date getDate() {
return this.date;
}
@@ -80,7 +81,7 @@ public class Visit extends BaseEntity {
*
* @param date New value of property date.
*/
- public void setDate(LocalDate date) {
+ public void setDate(Date date) {
this.date = date;
}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java
index 74cbc06b5..c54880de3 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRepositoryImpl.java
@@ -32,7 +32,6 @@ import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.samples.petclinic.model.Owner;
import org.springframework.samples.petclinic.model.Pet;
import org.springframework.samples.petclinic.model.PetType;
-import org.springframework.samples.petclinic.model.Visit;
import org.springframework.samples.petclinic.repository.OwnerRepository;
import org.springframework.samples.petclinic.repository.PetRepository;
import org.springframework.samples.petclinic.repository.VisitRepository;
@@ -115,7 +114,7 @@ public class JdbcPetRepositoryImpl implements PetRepository {
return new MapSqlParameterSource()
.addValue("id", pet.getId())
.addValue("name", pet.getName())
- .addValue("birth_date", pet.getBirthDate().toDate())
+ .addValue("birth_date", pet.getBirthDate())
.addValue("type_id", pet.getType().getId())
.addValue("owner_id", pet.getOwner().getId());
}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java
index 6420df163..9c6c101e4 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcPetRowMapper.java
@@ -19,8 +19,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
import org.springframework.jdbc.core.RowMapper;
/**
@@ -35,7 +33,7 @@ class JdbcPetRowMapper implements RowMapper {
pet.setId(rs.getInt("pets.id"));
pet.setName(rs.getString("name"));
Date birthDate = rs.getDate("birth_date");
- pet.setBirthDate(new LocalDate(birthDate));
+ pet.setBirthDate(new Date(birthDate.getTime()));
pet.setTypeId(rs.getInt("type_id"));
pet.setOwnerId(rs.getInt("owner_id"));
return pet;
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java
index ecae18d99..521f66952 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryImpl.java
@@ -17,7 +17,6 @@ package org.springframework.samples.petclinic.repository.jdbc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
@@ -77,7 +76,7 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
private MapSqlParameterSource createVisitParameterSource(Visit visit) {
return new MapSqlParameterSource()
.addValue("id", visit.getId())
- .addValue("visit_date", visit.getDate().toDate())
+ .addValue("visit_date", visit.getDate())
.addValue("description", visit.getDescription())
.addValue("pet_id", visit.getPet().getId());
}
@@ -92,13 +91,13 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
new JdbcPetRowMapper());
List visits = this.jdbcTemplate.query(
- "SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=:id",
+ "SELECT id as visit_id, visit_date, description FROM visits WHERE pet_id=:id",
params, new JdbcVisitRowMapper());
-
+
for (Visit visit: visits) {
visit.setPet(pet);
}
-
+
return visits;
}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java
index edc4527a3..0b172d3ec 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRowMapper.java
@@ -16,7 +16,6 @@
package org.springframework.samples.petclinic.repository.jdbc;
-import org.joda.time.LocalDate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.samples.petclinic.model.Visit;
@@ -35,7 +34,7 @@ class JdbcVisitRowMapper implements RowMapper {
Visit visit = new Visit();
visit.setId(rs.getInt("visit_id"));
Date visitDate = rs.getDate("visit_date");
- visit.setDate(new LocalDate(visitDate));
+ visit.setDate(new Date(visitDate.getTime()));
visit.setDescription(rs.getString("description"));
return visit;
}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java
index e4c222b65..8a8f758cb 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryImpl.java
@@ -15,16 +15,14 @@
*/
package org.springframework.samples.petclinic.repository.jpa;
-import java.util.Collection;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import org.springframework.cache.annotation.Cacheable;
import org.springframework.samples.petclinic.model.Vet;
import org.springframework.samples.petclinic.repository.VetRepository;
import org.springframework.stereotype.Repository;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.Collection;
+
/**
* JPA implementation of the {@link VetRepository} interface.
*
@@ -42,7 +40,6 @@ public class JpaVetRepositoryImpl implements VetRepository {
@Override
- @Cacheable(value = "vets")
@SuppressWarnings("unchecked")
public Collection findAll() {
return this.em.createQuery("SELECT distinct vet FROM Vet vet left join fetch vet.specialties ORDER BY vet.lastName, vet.firstName").getResultList();
diff --git a/src/main/resources/dandelion/datatables/datatables.properties b/src/main/resources/dandelion/datatables/datatables.properties
deleted file mode 100644
index 08b1e439c..000000000
--- a/src/main/resources/dandelion/datatables/datatables.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# ==================================
-# Dandelion-Datatables configuration
-# ==================================
-
-# Disable the asset management of Dandelion-Core for all non-DataTable-related assets
-main.standalone=true
\ No newline at end of file
diff --git a/src/main/resources/spring/data-access.properties b/src/main/resources/spring/data-access.properties
index e22ce1df6..2e32ca6d0 100644
--- a/src/main/resources/spring/data-access.properties
+++ b/src/main/resources/spring/data-access.properties
@@ -4,38 +4,16 @@
# various application context XML files (e.g., "applicationContext-*.xml").
# 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
jdbc.initLocation=db/hsqldb/initDB.sql
jdbc.dataLocation=db/hsqldb/populateDB.sql
-# Property that determines which database to use with an AbstractJpaVendorAdapter
-jpa.database=HSQL
-
jpa.showSql=true
-#-------------------------------------------------------------------------------
-# MySQL Settings
-
-#jdbc.driverClassName=com.mysql.jdbc.Driver
-#jdbc.url=jdbc:mysql://localhost:3306/petclinic
-#jdbc.username=root
-#jdbc.password=
-
-# Properties that control the population of schema and data for a new data source
-#jdbc.initLocation=classpath:db/mysql/initDB.sql
-#jdbc.dataLocation=classpath:db/mysql/populateDB.sql
-
-# Property that determines which Hibernate dialect to use
-# (only applied with "applicationContext-hibernate.xml")
-#hibernate.dialect=org.hibernate.dialect.MySQLDialect
+jdbc.driverClassName=${jdbc.driverClassName}
+jdbc.url=${jdbc.url}
+jdbc.username=${jdbc.username}
+jdbc.password=${jdbc.password}
# Property that determines which database to use with an AbstractJpaVendorAdapter
-#jpa.database=MYSQL
+jpa.database=${jpa.database}
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp
index 7ca50f673..877e53e8b 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp
@@ -3,7 +3,6 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ 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" %>
@@ -54,7 +53,7 @@
Name
Birth Date
-
+
Type
@@ -69,7 +68,7 @@
- |
+ |
|
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
index 2f862488f..08b1605cf 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
@@ -3,31 +3,46 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ 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" %>
Owners
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Name |
+ Address |
+ City |
+ Telephone |
+ Pets |
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp
index df70223c0..b964e83d4 100644
--- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp
+++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp
@@ -3,7 +3,6 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
@@ -30,7 +29,7 @@
|
- |
+ |
|
|
@@ -60,7 +59,7 @@
- |
+ |
|
diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
index d8e48e853..a46434a7f 100644
--- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
+++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
@@ -2,24 +2,34 @@
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
Veterinarians
-
-
-
-
-
-
-
-
- none
-
-
+
+
+
+ Name |
+ Specialties |
+
+
+
+
+
+
+
+ |
+
+
+
+
+ none
+ |
+
+
+
+
|