diff --git a/.editorconfig b/.editorconfig
index 8d67bc7a5..86fab8827 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,12 +1,12 @@
-# top-most EditorConfig file
-root = true
-
-[*]
-charset = utf-8
-end_of_line = lf
-insert_final_newline = true
-indent_style = space
-
-[*.{java,xml}]
-indent_size = 4
-trim_trailing_whitespace = true
+# top-most EditorConfig file
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+
+[*.{java,xml}]
+indent_size = 4
+trim_trailing_whitespace = true
diff --git a/.gitignore b/.gitignore
index b4fb36c37..0866f9be3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,9 @@
-target/*
-.settings/*
-.classpath
-.project
-.idea
-*.iml
-/target
-_site/
-.DS_Store
+target/*
+.settings/*
+.classpath
+.project
+.idea
+*.iml
+/target
+_site/
+.DS_Store
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index 25cc8af3c..35a6d06c3 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1 +1 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip
diff --git a/.springBeans b/.springBeans
index 44f18becd..3a9e788ac 100644
--- a/.springBeans
+++ b/.springBeans
@@ -1,20 +1,20 @@
-
-
- 1
-
-
-
-
-
-
- src/main/resources/spring/datasource-config.xml
- src/main/resources/spring/mvc-core-config.xml
- src/main/resources/spring/mvc-view-config.xml
- src/main/resources/spring/business-config.xml
-
-
- src/main/resources/spring/tools-config.xml
-
-
-
-
+
+
+ 1
+
+
+
+
+
+
+ src/main/resources/spring/datasource-config.xml
+ src/main/resources/spring/mvc-core-config.xml
+ src/main/resources/spring/mvc-view-config.xml
+ src/main/resources/spring/business-config.xml
+
+
+ src/main/resources/spring/tools-config.xml
+
+
+
+
diff --git a/.travis.yml b/.travis.yml
index c0f28cfa4..9ff99e4ad 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,2 +1,2 @@
-language: java
-jdk: oraclejdk8
+language: java
+jdk: oraclejdk8
diff --git a/docker-compose.yml b/docker-compose.yml
index 1631ec9fa..f11113f73 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,9 +1,9 @@
-mysql:
- image: mysql
- ports:
- - "3306:3306"
- environment:
- - MYSQL_ROOT_PASSWORD=root
- - MYSQL_DATABASE=test
- volumes:
+mysql:
+ image: mysql
+ ports:
+ - "3306:3306"
+ environment:
+ - MYSQL_ROOT_PASSWORD=root
+ - MYSQL_DATABASE=test
+ volumes:
- "./conf.d:/etc/mysql/conf.d:ro"
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ff677d097..90d1f9570 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,229 +1,229 @@
-
-
- 4.0.0
- org.springframework.samples
- spring-petclinic
- 1.5.1
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.1.RELEASE
-
- petclinic
-
-
-
-
- 1.8
- UTF-8
- UTF-8
-
-
- 3.3.6
- 1.11.4
- 2.2.4
- 1.8.0
-
- 3.0.2.RELEASE
-
- 2.7
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
- org.springframework.boot
- spring-boot-starter-cache
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
- nz.net.ultraq.thymeleaf
- thymeleaf-layout-dialect
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- org.hsqldb
- hsqldb
- runtime
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
-
- javax.cache
- cache-api
-
-
- org.ehcache
- ehcache
-
-
-
-
- org.webjars
- webjars-locator
-
-
- org.webjars
- jquery
- ${webjars-jquery.version}
-
-
- org.webjars
- jquery-ui
- ${webjars-jquery-ui.version}
-
-
- org.webjars
- bootstrap
- ${webjars-bootstrap.version}
-
-
-
-
- org.springframework.boot
- spring-boot-devtools
- runtime
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
- build-info
-
-
-
- ${project.build.sourceEncoding}
- ${project.reporting.outputEncoding}
- ${maven.compiler.source}
- ${maven.compiler.target}
-
-
-
-
-
-
- org.codehaus.mojo
- cobertura-maven-plugin
- ${cobertura.version}
-
-
-
-
-
-
- clean
- check
-
-
-
-
-
-
-
- pl.project13.maven
- git-commit-id-plugin
-
-
-
- revision
-
-
-
-
- true
- yyyy-MM-dd'T'HH:mm:ssZ
- true
- ${project.build.outputDirectory}/git.properties
-
- false
-
-
-
-
- ro.isdc.wro4j
- wro4j-maven-plugin
- ${wro4j.version}
-
-
- generate-resources
-
- run
-
-
-
-
- ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
- ${project.build.directory}/classes/static/resources/css
- ${basedir}/src/main/wro/wro.xml
- ${basedir}/src/main/wro/wro.properties
- ${basedir}/src/main/less
-
-
-
- org.webjars
- bootstrap
- ${webjars-bootstrap.version}
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- cobertura-maven-plugin
- ${cobertura.version}
-
-
- html
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+ org.springframework.samples
+ spring-petclinic
+ 1.5.1
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.1.RELEASE
+
+ petclinic
+
+
+
+
+ 1.8
+ UTF-8
+ UTF-8
+
+
+ 3.3.6
+ 1.11.4
+ 2.2.4
+ 1.8.0
+
+ 3.0.2.RELEASE
+
+ 2.7
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+ nz.net.ultraq.thymeleaf
+ thymeleaf-layout-dialect
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ org.hsqldb
+ hsqldb
+ runtime
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+
+
+ javax.cache
+ cache-api
+
+
+ org.ehcache
+ ehcache
+
+
+
+
+ org.webjars
+ webjars-locator
+
+
+ org.webjars
+ jquery
+ ${webjars-jquery.version}
+
+
+ org.webjars
+ jquery-ui
+ ${webjars-jquery-ui.version}
+
+
+ org.webjars
+ bootstrap
+ ${webjars-bootstrap.version}
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+ build-info
+
+
+
+ ${project.build.sourceEncoding}
+ ${project.reporting.outputEncoding}
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${cobertura.version}
+
+
+
+
+
+
+ clean
+ check
+
+
+
+
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+
+
+
+ revision
+
+
+
+
+ true
+ yyyy-MM-dd'T'HH:mm:ssZ
+ true
+ ${project.build.outputDirectory}/git.properties
+
+ false
+
+
+
+
+ ro.isdc.wro4j
+ wro4j-maven-plugin
+ ${wro4j.version}
+
+
+ generate-resources
+
+ run
+
+
+
+
+ ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
+ ${project.build.directory}/classes/static/resources/css
+ ${basedir}/src/main/wro/wro.xml
+ ${basedir}/src/main/wro/wro.properties
+ ${basedir}/src/main/less
+
+
+
+ org.webjars
+ bootstrap
+ ${webjars-bootstrap.version}
+
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${cobertura.version}
+
+
+ html
+
+
+
+
+
+
+
+
diff --git a/readme.md b/readme.md
index 56a6639cb..ba3486925 100644
--- a/readme.md
+++ b/readme.md
@@ -1,9 +1,9 @@
-# Spring KidClinic Sample Application
-
-## Running kidclinic locally
-```
- cd kidclinic
- ./mvnw spring-boot:run
-```
-
+# Spring KidClinic Sample Application
+
+## Running kidclinic locally
+```
+ cd kidclinic
+ ./mvnw spring-boot:run
+```
+
You can then access kidclinic here: http://localhost:8080/
\ No newline at end of file
diff --git a/sonar-project.properties b/sonar-project.properties
index d84ed7c2d..104418194 100755
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,13 +1,13 @@
-# Required metadata
-sonar.projectKey=java-sonar-runner-simple
-sonar.projectName=Simple Java project analyzed with the SonarQube Runner
-sonar.projectVersion=1.0
-
-# Comma-separated paths to directories with sources (required)
-sonar.sources=src
-
-# Language
-sonar.language=java
-
-# Encoding of the source files
+# Required metadata
+sonar.projectKey=java-sonar-runner-simple
+sonar.projectName=Simple Java project analyzed with the SonarQube Runner
+sonar.projectVersion=1.0
+
+# Comma-separated paths to directories with sources (required)
+sonar.sources=src
+
+# Language
+sonar.language=java
+
+# Encoding of the source files
sonar.sourceEncoding=UTF-8
\ No newline at end of file
diff --git a/src/main/java/org/springframework/samples/kidclinic/KidClinicApplication.java b/src/main/java/org/springframework/samples/kidclinic/KidClinicApplication.java
index 6541ec2d9..5b7677f64 100644
--- a/src/main/java/org/springframework/samples/kidclinic/KidClinicApplication.java
+++ b/src/main/java/org/springframework/samples/kidclinic/KidClinicApplication.java
@@ -1,35 +1,35 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.samples.kidclinic;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-/**
- * KidClinic Spring Boot Application.
- *
- * @author Dave Syer
- *
- */
-@SpringBootApplication
-public class KidClinicApplication {
-
- public static void main(String[] args) throws Exception {
- SpringApplication.run(KidClinicApplication.class, args);
- }
-
-}
+/*
+ * Copyright 2002-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.samples.kidclinic;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * KidClinic Spring Boot Application.
+ *
+ * @author Dave Syer
+ *
+ */
+@SpringBootApplication
+public class KidClinicApplication {
+
+ public static void main(String[] args) throws Exception {
+ SpringApplication.run(KidClinicApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/doctor/Doctor.java b/src/main/java/org/springframework/samples/kidclinic/doctor/Doctor.java
index 2965f9505..ffd47a76d 100644
--- a/src/main/java/org/springframework/samples/kidclinic/doctor/Doctor.java
+++ b/src/main/java/org/springframework/samples/kidclinic/doctor/Doctor.java
@@ -1,79 +1,79 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.doctor;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-import javax.xml.bind.annotation.XmlElement;
-
-import org.springframework.beans.support.MutableSortDefinition;
-import org.springframework.beans.support.PropertyComparator;
-import org.springframework.samples.kidclinic.model.Person;
-
-/**
- * Simple JavaBean domain object representing a veterinarian.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Arjen Poutsma
- */
-@Entity
-@Table(name = "doctors")
-public class Doctor extends Person {
-
- @ManyToMany(fetch = FetchType.EAGER)
- @JoinTable(name = "doctor_specialties", joinColumns = @JoinColumn(name = "doctor_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
- private Set specialties;
-
- protected Set getSpecialtiesInternal() {
- if (this.specialties == null) {
- this.specialties = new HashSet<>();
- }
- return this.specialties;
- }
-
- protected void setSpecialtiesInternal(Set specialties) {
- this.specialties = specialties;
- }
-
- @XmlElement
- public List getSpecialties() {
- List sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
- PropertyComparator.sort(sortedSpecs,
- new MutableSortDefinition("name", true, true));
- return Collections.unmodifiableList(sortedSpecs);
- }
-
- public int getNrOfSpecialties() {
- return getSpecialtiesInternal().size();
- }
-
- public void addSpecialty(Specialty specialty) {
- getSpecialtiesInternal().add(specialty);
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.doctor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+import org.springframework.samples.kidclinic.model.Person;
+
+/**
+ * Simple JavaBean domain object representing a veterinarian.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ * @author Arjen Poutsma
+ */
+@Entity
+@Table(name = "doctors")
+public class Doctor extends Person {
+
+ @ManyToMany(fetch = FetchType.EAGER)
+ @JoinTable(name = "doctor_specialties", joinColumns = @JoinColumn(name = "doctor_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
+ private Set specialties;
+
+ protected Set getSpecialtiesInternal() {
+ if (this.specialties == null) {
+ this.specialties = new HashSet<>();
+ }
+ return this.specialties;
+ }
+
+ protected void setSpecialtiesInternal(Set specialties) {
+ this.specialties = specialties;
+ }
+
+ @XmlElement
+ public List getSpecialties() {
+ List sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
+ PropertyComparator.sort(sortedSpecs,
+ new MutableSortDefinition("name", true, true));
+ return Collections.unmodifiableList(sortedSpecs);
+ }
+
+ public int getNrOfSpecialties() {
+ return getSpecialtiesInternal().size();
+ }
+
+ public void addSpecialty(Specialty specialty) {
+ getSpecialtiesInternal().add(specialty);
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java b/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java
index 7fa5adb6a..88f0a8f43 100644
--- a/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java
+++ b/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java
@@ -1,60 +1,60 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.doctor;
-
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * @author Juergen Hoeller
- * @author Mark Fisher
- * @author Ken Krebs
- * @author Arjen Poutsma
- */
-@Controller
-class DoctorController {
-
- private final DoctorRepository doctors;
-
- @Autowired
- public DoctorController(DoctorRepository clinicService) {
- this.doctors = clinicService;
- }
-
- @RequestMapping(value = { "/doctors.html" })
- public String showDoctorList(Map model) {
- // Here we are returning an object of type 'Doctors' rather than a collection of Doctor
- // objects so it is simpler for Object-Xml mapping
- Doctors doctors = new Doctors();
- doctors.getDoctorList().addAll(this.doctors.findAll());
- model.put("doctors", doctors);
- return "doctors/doctorList";
- }
-
- @RequestMapping(value = { "/doctors.json", "/doctors.xml" })
- public @ResponseBody Doctors showResourcesVetList() {
- // Here we are returning an object of type 'Doctors' rather than a collection of Doctor
- // objects so it is simpler for JSon/Object mapping
- Doctors doctors = new Doctors();
- doctors.getDoctorList().addAll(this.doctors.findAll());
- return doctors;
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.doctor;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author Juergen Hoeller
+ * @author Mark Fisher
+ * @author Ken Krebs
+ * @author Arjen Poutsma
+ */
+@Controller
+class DoctorController {
+
+ private final DoctorRepository doctors;
+
+ @Autowired
+ public DoctorController(DoctorRepository clinicService) {
+ this.doctors = clinicService;
+ }
+
+ @RequestMapping(value = { "/doctors.html" })
+ public String showDoctorList(Map model) {
+ // Here we are returning an object of type 'Doctors' rather than a collection of Doctor
+ // objects so it is simpler for Object-Xml mapping
+ Doctors doctors = new Doctors();
+ doctors.getDoctorList().addAll(this.doctors.findAll());
+ model.put("doctors", doctors);
+ return "doctors/doctorList";
+ }
+
+ @RequestMapping(value = { "/doctors.json", "/doctors.xml" })
+ public @ResponseBody Doctors showResourcesVetList() {
+ // Here we are returning an object of type 'Doctors' rather than a collection of Doctor
+ // objects so it is simpler for JSon/Object mapping
+ Doctors doctors = new Doctors();
+ doctors.getDoctorList().addAll(this.doctors.findAll());
+ return doctors;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorRepository.java b/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorRepository.java
index a250efd83..f8412afa7 100644
--- a/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorRepository.java
+++ b/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorRepository.java
@@ -1,46 +1,46 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.doctor;
-
-import java.util.Collection;
-
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.repository.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Repository class for Doctor domain objects All method names are compliant with Spring Data naming
- * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-public interface DoctorRepository extends Repository {
-
- /**
- * Retrieve all Doctors from the data store.
- *
- * @return a Collection of Doctors
- */
- @Transactional(readOnly = true)
- @Cacheable("doctors")
- Collection findAll() throws DataAccessException;
-
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.doctor;
+
+import java.util.Collection;
+
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.dao.DataAccessException;
+import org.springframework.data.repository.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Repository class for Doctor domain objects All method names are compliant with Spring Data naming
+ * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ * @author Michael Isvy
+ */
+public interface DoctorRepository extends Repository {
+
+ /**
+ * Retrieve all Doctors from the data store.
+ *
+ * @return a Collection of Doctors
+ */
+ @Transactional(readOnly = true)
+ @Cacheable("doctors")
+ Collection findAll() throws DataAccessException;
+
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/doctor/Doctors.java b/src/main/java/org/springframework/samples/kidclinic/doctor/Doctors.java
index 9f3f9f900..d44fcc570 100644
--- a/src/main/java/org/springframework/samples/kidclinic/doctor/Doctors.java
+++ b/src/main/java/org/springframework/samples/kidclinic/doctor/Doctors.java
@@ -1,43 +1,43 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.doctor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Simple domain object representing a list of doctors. Mostly here to be used for the 'doctors' {@link
- * org.springframework.web.servlet.view.xml.MarshallingView}.
- *
- * @author Arjen Poutsma
- */
-@XmlRootElement
-public class Doctors {
-
- private List doctors;
-
- @XmlElement
- public List getDoctorList() {
- if (doctors == null) {
- doctors = new ArrayList<>();
- }
- return doctors;
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.doctor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Simple domain object representing a list of doctors. Mostly here to be used for the 'doctors' {@link
+ * org.springframework.web.servlet.view.xml.MarshallingView}.
+ *
+ * @author Arjen Poutsma
+ */
+@XmlRootElement
+public class Doctors {
+
+ private List doctors;
+
+ @XmlElement
+ public List getDoctorList() {
+ if (doctors == null) {
+ doctors = new ArrayList<>();
+ }
+ return doctors;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/doctor/Specialty.java b/src/main/java/org/springframework/samples/kidclinic/doctor/Specialty.java
index 6da0cfe67..17d41ecdf 100644
--- a/src/main/java/org/springframework/samples/kidclinic/doctor/Specialty.java
+++ b/src/main/java/org/springframework/samples/kidclinic/doctor/Specialty.java
@@ -1,34 +1,34 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.doctor;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.Table;
-
-import org.springframework.samples.kidclinic.model.NamedEntity;
-
-/**
- * Models a {@link Doctor Doctor's} specialty (for example, dentistry).
- *
- * @author Juergen Hoeller
- */
-@Entity
-@Table(name = "specialties")
-public class Specialty extends NamedEntity implements Serializable {
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.doctor;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import org.springframework.samples.kidclinic.model.NamedEntity;
+
+/**
+ * Models a {@link Doctor Doctor's} specialty (for example, dentistry).
+ *
+ * @author Juergen Hoeller
+ */
+@Entity
+@Table(name = "specialties")
+public class Specialty extends NamedEntity implements Serializable {
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/model/BaseEntity.java b/src/main/java/org/springframework/samples/kidclinic/model/BaseEntity.java
index 0fb2648fe..8e35af234 100644
--- a/src/main/java/org/springframework/samples/kidclinic/model/BaseEntity.java
+++ b/src/main/java/org/springframework/samples/kidclinic/model/BaseEntity.java
@@ -1,50 +1,50 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.model;
-
-import java.io.Serializable;
-
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-
-/**
- * Simple JavaBean domain object with an id property. Used as a base class for objects
- * needing this property.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- */
-@MappedSuperclass
-public class BaseEntity implements Serializable {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Integer id;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public boolean isNew() {
- return this.id == null;
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.model;
+
+import java.io.Serializable;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+/**
+ * Simple JavaBean domain object with an id property. Used as a base class for objects
+ * needing this property.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ */
+@MappedSuperclass
+public class BaseEntity implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public boolean isNew() {
+ return this.id == null;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/model/NamedEntity.java b/src/main/java/org/springframework/samples/kidclinic/model/NamedEntity.java
index 8231de7d9..151712ae1 100644
--- a/src/main/java/org/springframework/samples/kidclinic/model/NamedEntity.java
+++ b/src/main/java/org/springframework/samples/kidclinic/model/NamedEntity.java
@@ -1,48 +1,48 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.model;
-
-import javax.persistence.Column;
-import javax.persistence.MappedSuperclass;
-
-
-/**
- * Simple JavaBean domain object adds a name property to BaseEntity. Used as a base class for objects
- * needing these properties.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- */
-@MappedSuperclass
-public class NamedEntity extends BaseEntity {
-
- @Column(name = "name")
- private String name;
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return this.getName();
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.model;
+
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+
+
+/**
+ * Simple JavaBean domain object adds a name property to BaseEntity. Used as a base class for objects
+ * needing these properties.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ */
+@MappedSuperclass
+public class NamedEntity extends BaseEntity {
+
+ @Column(name = "name")
+ private String name;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return this.getName();
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/model/Person.java b/src/main/java/org/springframework/samples/kidclinic/model/Person.java
index 8ef8d2693..38fa1ca95 100644
--- a/src/main/java/org/springframework/samples/kidclinic/model/Person.java
+++ b/src/main/java/org/springframework/samples/kidclinic/model/Person.java
@@ -1,55 +1,55 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.model;
-
-import javax.persistence.Column;
-import javax.persistence.MappedSuperclass;
-
-import org.hibernate.validator.constraints.NotEmpty;
-
-/**
- * Simple JavaBean domain object representing an person.
- *
- * @author Ken Krebs
- */
-@MappedSuperclass
-public class Person extends BaseEntity {
-
- @Column(name = "first_name")
- @NotEmpty
- private String firstName;
-
- @Column(name = "last_name")
- @NotEmpty
- private String lastName;
-
- public String getFirstName() {
- return this.firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return this.lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.model;
+
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+
+import org.hibernate.validator.constraints.NotEmpty;
+
+/**
+ * Simple JavaBean domain object representing an person.
+ *
+ * @author Ken Krebs
+ */
+@MappedSuperclass
+public class Person extends BaseEntity {
+
+ @Column(name = "first_name")
+ @NotEmpty
+ private String firstName;
+
+ @Column(name = "last_name")
+ @NotEmpty
+ private String lastName;
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/model/package-info.java b/src/main/java/org/springframework/samples/kidclinic/model/package-info.java
index 4387a1ad3..bac1b029c 100644
--- a/src/main/java/org/springframework/samples/kidclinic/model/package-info.java
+++ b/src/main/java/org/springframework/samples/kidclinic/model/package-info.java
@@ -1,5 +1,5 @@
-/**
- * The classes in this package represent utilities used by the domain.
- */
-package org.springframework.samples.kidclinic.model;
-
+/**
+ * The classes in this package represent utilities used by the domain.
+ */
+package org.springframework.samples.kidclinic.model;
+
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/Kid.java b/src/main/java/org/springframework/samples/kidclinic/parent/Kid.java
index d7a1f6ca0..84835eed2 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/Kid.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/Kid.java
@@ -1,117 +1,117 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.springframework.beans.support.MutableSortDefinition;
-import org.springframework.beans.support.PropertyComparator;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.samples.kidclinic.model.NamedEntity;
-import org.springframework.samples.kidclinic.visit.Visit;
-
-/**
- * Simple business object representing a pet.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- */
-@Entity
-@Table(name = "kids")
-public class Kid extends NamedEntity {
-
- @Column(name = "birth_date")
- @Temporal(TemporalType.DATE)
- @DateTimeFormat(pattern = "yyyy/MM/dd")
- private Date birthDate;
-
- @ManyToOne
- @JoinColumn(name = "gender_id")
- private KidGender gender;
-
- @ManyToOne
- @JoinColumn(name = "parent_id")
- private Parent parent;
-
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "kidId", fetch = FetchType.EAGER)
- private Set visits = new LinkedHashSet<>();
-
- public void setBirthDate(Date birthDate) {
- this.birthDate = birthDate;
- }
-
- public Date getBirthDate() {
- return this.birthDate;
- }
-
- public KidGender getGender() {
- return this.gender;
- }
-
- public void setGender(KidGender gender) {
- this.gender = gender;
- }
-
- public Parent getParent() {
- return this.parent;
- }
-
- protected void setParent(Parent parent) {
- this.parent = parent;
- }
-
- protected Set getVisitsInternal() {
- if (this.visits == null) {
- this.visits = new HashSet<>();
- }
- return this.visits;
- }
-
- protected void setVisitsInternal(Set visits) {
- this.visits = visits;
- }
-
- public List getVisits() {
- List sortedVisits = new ArrayList<>(getVisitsInternal());
- PropertyComparator.sort(sortedVisits,
- new MutableSortDefinition("date", false, false));
- return Collections.unmodifiableList(sortedVisits);
- }
-
- public void addVisit(Visit visit) {
- getVisitsInternal().add(visit);
- visit.setKidId(this.getId());
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.samples.kidclinic.model.NamedEntity;
+import org.springframework.samples.kidclinic.visit.Visit;
+
+/**
+ * Simple business object representing a pet.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ */
+@Entity
+@Table(name = "kids")
+public class Kid extends NamedEntity {
+
+ @Column(name = "birth_date")
+ @Temporal(TemporalType.DATE)
+ @DateTimeFormat(pattern = "yyyy/MM/dd")
+ private Date birthDate;
+
+ @ManyToOne
+ @JoinColumn(name = "gender_id")
+ private KidGender gender;
+
+ @ManyToOne
+ @JoinColumn(name = "parent_id")
+ private Parent parent;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "kidId", fetch = FetchType.EAGER)
+ private Set visits = new LinkedHashSet<>();
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+ public Date getBirthDate() {
+ return this.birthDate;
+ }
+
+ public KidGender getGender() {
+ return this.gender;
+ }
+
+ public void setGender(KidGender gender) {
+ this.gender = gender;
+ }
+
+ public Parent getParent() {
+ return this.parent;
+ }
+
+ protected void setParent(Parent parent) {
+ this.parent = parent;
+ }
+
+ protected Set getVisitsInternal() {
+ if (this.visits == null) {
+ this.visits = new HashSet<>();
+ }
+ return this.visits;
+ }
+
+ protected void setVisitsInternal(Set visits) {
+ this.visits = visits;
+ }
+
+ public List getVisits() {
+ List sortedVisits = new ArrayList<>(getVisitsInternal());
+ PropertyComparator.sort(sortedVisits,
+ new MutableSortDefinition("date", false, false));
+ return Collections.unmodifiableList(sortedVisits);
+ }
+
+ public void addVisit(Visit visit) {
+ getVisitsInternal().add(visit);
+ visit.setKidId(this.getId());
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/KidController.java b/src/main/java/org/springframework/samples/kidclinic/parent/KidController.java
index ed2349395..216dc9147 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/KidController.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/KidController.java
@@ -1,116 +1,116 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.Collection;
-
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.ModelMap;
-import org.springframework.util.StringUtils;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-/**
- * @author Juergen Hoeller
- * @author Ken Krebs
- * @author Arjen Poutsma
- */
-@Controller
-@RequestMapping("/parents/{parentId}")
-class KidController {
-
- private static final String VIEWS_KIDS_CREATE_OR_UPDATE_FORM = "kids/createOrUpdateKidForm";
- private final KidRepository kids;
- private final ParentRepository parents;
-
- @Autowired
- public KidController(KidRepository kids, ParentRepository parents) {
- this.kids = kids;
- this.parents = parents;
- }
-
- @ModelAttribute("gender")
- public Collection populateKidGenders() {
- return this.kids.findKidGenders();
- }
-
- @ModelAttribute("parent")
- public Parent findParent(@PathVariable("parentId") int parentId) {
- return this.parents.findById(parentId);
- }
-
- @InitBinder("parent")
- public void initParentBinder(WebDataBinder dataBinder) {
- dataBinder.setDisallowedFields("id");
- }
-
- @InitBinder("kid")
- public void initKidBinder(WebDataBinder dataBinder) {
- dataBinder.setValidator(new KidValidator());
- }
-
- @RequestMapping(value = "/kids/new", method = RequestMethod.GET)
- public String initCreationForm(Parent parent, ModelMap model) {
- Kid kid = new Kid();
- parent.addKid(kid);
- model.put("kid", kid);
- return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
- }
-
- @RequestMapping(value = "/kids/new", method = RequestMethod.POST)
- public String processCreationForm(Parent parent, @Valid Kid kid, BindingResult result, ModelMap model) {
- if (StringUtils.hasLength(kid.getName()) && kid.isNew() && parent.getKid(kid.getName(), true) != null){
- result.rejectValue("name", "duplicate", "already exists");
- }
- if (result.hasErrors()) {
- model.put("kid", kid);
- return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
- } else {
- parent.addKid(kid);
- this.kids.save(kid);
- return "redirect:/parents/{parentId}";
- }
- }
-
- @RequestMapping(value = "/kids/{kidId}/edit", method = RequestMethod.GET)
- public String initUpdateForm(@PathVariable("kidId") int kidId, ModelMap model) {
- Kid kid = this.kids.findById(kidId);
- model.put("kid", kid);
- return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
- }
-
- @RequestMapping(value = "/kids/{kidsId}/edit", method = RequestMethod.POST)
- public String processUpdateForm(@Valid Kid kid, BindingResult result, Parent parent, ModelMap model) {
- if (result.hasErrors()) {
- kid.setParent(parent);
- model.put("kid", kid);
- return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
- } else {
- parent.addKid(kid);
- this.kids.save(kid);
- return "redirect:/parents/{parentId}";
- }
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.Collection;
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.StringUtils;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * @author Juergen Hoeller
+ * @author Ken Krebs
+ * @author Arjen Poutsma
+ */
+@Controller
+@RequestMapping("/parents/{parentId}")
+class KidController {
+
+ private static final String VIEWS_KIDS_CREATE_OR_UPDATE_FORM = "kids/createOrUpdateKidForm";
+ private final KidRepository kids;
+ private final ParentRepository parents;
+
+ @Autowired
+ public KidController(KidRepository kids, ParentRepository parents) {
+ this.kids = kids;
+ this.parents = parents;
+ }
+
+ @ModelAttribute("gender")
+ public Collection populateKidGenders() {
+ return this.kids.findKidGenders();
+ }
+
+ @ModelAttribute("parent")
+ public Parent findParent(@PathVariable("parentId") int parentId) {
+ return this.parents.findById(parentId);
+ }
+
+ @InitBinder("parent")
+ public void initParentBinder(WebDataBinder dataBinder) {
+ dataBinder.setDisallowedFields("id");
+ }
+
+ @InitBinder("kid")
+ public void initKidBinder(WebDataBinder dataBinder) {
+ dataBinder.setValidator(new KidValidator());
+ }
+
+ @RequestMapping(value = "/kids/new", method = RequestMethod.GET)
+ public String initCreationForm(Parent parent, ModelMap model) {
+ Kid kid = new Kid();
+ parent.addKid(kid);
+ model.put("kid", kid);
+ return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
+ }
+
+ @RequestMapping(value = "/kids/new", method = RequestMethod.POST)
+ public String processCreationForm(Parent parent, @Valid Kid kid, BindingResult result, ModelMap model) {
+ if (StringUtils.hasLength(kid.getName()) && kid.isNew() && parent.getKid(kid.getName(), true) != null){
+ result.rejectValue("name", "duplicate", "already exists");
+ }
+ if (result.hasErrors()) {
+ model.put("kid", kid);
+ return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
+ } else {
+ parent.addKid(kid);
+ this.kids.save(kid);
+ return "redirect:/parents/{parentId}";
+ }
+ }
+
+ @RequestMapping(value = "/kids/{kidId}/edit", method = RequestMethod.GET)
+ public String initUpdateForm(@PathVariable("kidId") int kidId, ModelMap model) {
+ Kid kid = this.kids.findById(kidId);
+ model.put("kid", kid);
+ return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
+ }
+
+ @RequestMapping(value = "/kids/{kidsId}/edit", method = RequestMethod.POST)
+ public String processUpdateForm(@Valid Kid kid, BindingResult result, Parent parent, ModelMap model) {
+ if (result.hasErrors()) {
+ kid.setParent(parent);
+ model.put("kid", kid);
+ return VIEWS_KIDS_CREATE_OR_UPDATE_FORM;
+ } else {
+ parent.addKid(kid);
+ this.kids.save(kid);
+ return "redirect:/parents/{parentId}";
+ }
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/KidGender.java b/src/main/java/org/springframework/samples/kidclinic/parent/KidGender.java
index a5c40ec53..b06ef4bd4 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/KidGender.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/KidGender.java
@@ -1,31 +1,31 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import javax.persistence.Entity;
-import javax.persistence.Table;
-
-import org.springframework.samples.kidclinic.model.NamedEntity;
-
-/**
- * @author Juergen Hoeller
- * Can be Cat, Dog, Hamster...
- */
-@Entity
-@Table(name = "gender")
-public class KidGender extends NamedEntity {
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import org.springframework.samples.kidclinic.model.NamedEntity;
+
+/**
+ * @author Juergen Hoeller
+ * Can be Cat, Dog, Hamster...
+ */
+@Entity
+@Table(name = "gender")
+public class KidGender extends NamedEntity {
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/KidGenderFormatter.java b/src/main/java/org/springframework/samples/kidclinic/parent/KidGenderFormatter.java
index 7511c4a1d..74467002a 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/KidGenderFormatter.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/KidGenderFormatter.java
@@ -1,65 +1,65 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-
-import java.text.ParseException;
-import java.util.Collection;
-import java.util.Locale;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.format.Formatter;
-import org.springframework.stereotype.Component;
-
-/**
- * Instructs Spring MVC on how to parse and print elements of type 'KidGender'. Starting from Spring 3.0, Formatters have
- * come as an improvement in comparison to legacy PropertyEditors. See the following links for more details: - The
- * Spring ref doc: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/validation.html#format-Formatter-SPI
- * - A nice blog entry from Gordon Dickens: http://gordondickens.com/wordpress/2010/09/30/using-spring-3-0-custom-type-converter/
- *
- *
- * @author Mark Fisher
- * @author Juergen Hoeller
- * @author Michael Isvy
- */
-@Component
-public class KidGenderFormatter implements Formatter {
-
- private final KidRepository kids;
-
-
- @Autowired
- public KidGenderFormatter(KidRepository kids) {
- this.kids = kids;
- }
-
- @Override
- public String print(KidGender kidGender, Locale locale) {
- return kidGender.getName();
- }
-
- @Override
- public KidGender parse(String text, Locale locale) throws ParseException {
- Collection findKidGenders = this.kids.findKidGenders();
- for (KidGender gender : findKidGenders) {
- if (gender.getName().equals(text)) {
- return gender;
- }
- }
- throw new ParseException("gender not found: " + text, 0);
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Locale;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.Formatter;
+import org.springframework.stereotype.Component;
+
+/**
+ * Instructs Spring MVC on how to parse and print elements of type 'KidGender'. Starting from Spring 3.0, Formatters have
+ * come as an improvement in comparison to legacy PropertyEditors. See the following links for more details: - The
+ * Spring ref doc: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/validation.html#format-Formatter-SPI
+ * - A nice blog entry from Gordon Dickens: http://gordondickens.com/wordpress/2010/09/30/using-spring-3-0-custom-type-converter/
+ *
+ *
+ * @author Mark Fisher
+ * @author Juergen Hoeller
+ * @author Michael Isvy
+ */
+@Component
+public class KidGenderFormatter implements Formatter {
+
+ private final KidRepository kids;
+
+
+ @Autowired
+ public KidGenderFormatter(KidRepository kids) {
+ this.kids = kids;
+ }
+
+ @Override
+ public String print(KidGender kidGender, Locale locale) {
+ return kidGender.getName();
+ }
+
+ @Override
+ public KidGender parse(String text, Locale locale) throws ParseException {
+ Collection findKidGenders = this.kids.findKidGenders();
+ for (KidGender gender : findKidGenders) {
+ if (gender.getName().equals(text)) {
+ return gender;
+ }
+ }
+ throw new ParseException("gender not found: " + text, 0);
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/KidRepository.java b/src/main/java/org/springframework/samples/kidclinic/parent/KidRepository.java
index 3102ec7ce..d0ca26503 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/KidRepository.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/KidRepository.java
@@ -1,58 +1,58 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.List;
-
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Repository class for Kid domain objects All method names are compliant with Spring Data naming
- * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-public interface KidRepository extends Repository {
-
- /**
- * Retrieve all {@link KidGender}s from the data store.
- * @return a Collection of {@link KidGender}s.
- */
- @Query("SELECT ptype FROM KidGender ptype ORDER BY ptype.name")
- @Transactional(readOnly = true)
- List findKidGenders();
-
- /**
- * Retrieve a {@link Kid} from the data store by id.
- * @param id the id to search for
- * @return the {@link Kid} if found
- */
- @Transactional(readOnly = true)
- Kid findById(Integer id);
-
- /**
- * Save a {@link Kid} to the data store, either inserting or updating it.
- * @param kid the {@link Kid} to save
- */
- void save(Kid kid);
-
-}
-
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Repository class for Kid domain objects All method names are compliant with Spring Data naming
+ * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ * @author Michael Isvy
+ */
+public interface KidRepository extends Repository {
+
+ /**
+ * Retrieve all {@link KidGender}s from the data store.
+ * @return a Collection of {@link KidGender}s.
+ */
+ @Query("SELECT ptype FROM KidGender ptype ORDER BY ptype.name")
+ @Transactional(readOnly = true)
+ List findKidGenders();
+
+ /**
+ * Retrieve a {@link Kid} from the data store by id.
+ * @param id the id to search for
+ * @return the {@link Kid} if found
+ */
+ @Transactional(readOnly = true)
+ Kid findById(Integer id);
+
+ /**
+ * Save a {@link Kid} to the data store, either inserting or updating it.
+ * @param kid the {@link Kid} to save
+ */
+ void save(Kid kid);
+
+}
+
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/KidValidator.java b/src/main/java/org/springframework/samples/kidclinic/parent/KidValidator.java
index 4a65f4021..cc0b2c9bc 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/KidValidator.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/KidValidator.java
@@ -1,64 +1,64 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import org.springframework.util.StringUtils;
-import org.springframework.validation.Errors;
-import org.springframework.validation.Validator;
-
-/**
- * Validator for Kid forms.
- *
- * We're not using Bean Validation annotations here because it is easier to define such validation rule in Java.
- *
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- */
-public class KidValidator implements Validator {
-
- private static final String REQUIRED = "required";
-
- @Override
- public void validate(Object obj, Errors errors) {
- Kid kid = (Kid) obj;
- String name = kid.getName();
- // name validation
- if (!StringUtils.hasLength(name)) {
- errors.rejectValue("name", REQUIRED, REQUIRED);
- }
-
- // gender validation
- if (kid.isNew() && kid.getGender() == null) {
- errors.rejectValue("gender", REQUIRED, REQUIRED);
- }
-
- // birth date validation
- if (kid.getBirthDate() == null) {
- errors.rejectValue("birthDate", REQUIRED, REQUIRED);
- }
- }
-
- /**
- * This Validator validates *just* Kid instances
- */
- @Override
- public boolean supports(Class> clazz) {
- return Kid.class.isAssignableFrom(clazz);
- }
-
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import org.springframework.util.StringUtils;
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+
+/**
+ * Validator for Kid forms.
+ *
+ * We're not using Bean Validation annotations here because it is easier to define such validation rule in Java.
+ *
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ */
+public class KidValidator implements Validator {
+
+ private static final String REQUIRED = "required";
+
+ @Override
+ public void validate(Object obj, Errors errors) {
+ Kid kid = (Kid) obj;
+ String name = kid.getName();
+ // name validation
+ if (!StringUtils.hasLength(name)) {
+ errors.rejectValue("name", REQUIRED, REQUIRED);
+ }
+
+ // gender validation
+ if (kid.isNew() && kid.getGender() == null) {
+ errors.rejectValue("gender", REQUIRED, REQUIRED);
+ }
+
+ // birth date validation
+ if (kid.getBirthDate() == null) {
+ errors.rejectValue("birthDate", REQUIRED, REQUIRED);
+ }
+ }
+
+ /**
+ * This Validator validates *just* Kid instances
+ */
+ @Override
+ public boolean supports(Class> clazz) {
+ return Kid.class.isAssignableFrom(clazz);
+ }
+
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/Parent.java b/src/main/java/org/springframework/samples/kidclinic/parent/Parent.java
index 56f15963e..662c47aae 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/Parent.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/Parent.java
@@ -1,156 +1,156 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.validation.constraints.Digits;
-
-import org.hibernate.validator.constraints.NotEmpty;
-import org.springframework.beans.support.MutableSortDefinition;
-import org.springframework.beans.support.PropertyComparator;
-import org.springframework.core.style.ToStringCreator;
-import org.springframework.samples.kidclinic.model.Person;
-
-/**
- * Simple JavaBean domain object representing an parent.
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-@Entity
-@Table(name = "parents")
-public class Parent extends Person {
- @Column(name = "address")
- @NotEmpty
- private String address;
-
- @Column(name = "city")
- @NotEmpty
- private String city;
-
- @Column(name = "telephone")
- @NotEmpty
- @Digits(fraction = 0, integer = 10)
- private String telephone;
-
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent")
- private Set kids;
-
-
- public String getAddress() {
- return this.address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public String getCity() {
- return this.city;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getTelephone() {
- return this.telephone;
- }
-
- public void setTelephone(String telephone) {
- this.telephone = telephone;
- }
-
- protected Set getKidsInternal() {
- if (this.kids == null) {
- this.kids = new HashSet<>();
- }
- return this.kids;
- }
-
- protected void setKidsInternal(Set kids) {
- this.kids = kids;
- }
-
- public List getKids() {
- List sortedKids = new ArrayList<>(getKidsInternal());
- PropertyComparator.sort(sortedKids, new MutableSortDefinition("name", true, true));
- return Collections.unmodifiableList(sortedKids);
- }
-
- public void addKid(Kid kid) {
- if (kid.isNew()) {
- getKidsInternal().add(kid);
- }
- kid.setParent(this);
- }
-
- /**
- * Return the Kid with the given name, or null if none found for this Parent.
- *
- * @param name to test
- * @return true if kid name is already in use
- */
- public Kid getKid(String name) {
- return getKid(name, false);
- }
-
- /**
- * Return the Kid with the given name, or null if none found for this Kid.
- *
- * @param name to test
- * @return true if kid name is already in use
- */
- public Kid getKid(String name, boolean ignoreNew) {
- name = name.toLowerCase();
- for (Kid kid : getKidsInternal()) {
- if (!ignoreNew || !kid.isNew()) {
- String compName = kid.getName();
- compName = compName.toLowerCase();
- if (compName.equals(name)) {
- return kid;
- }
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- return new ToStringCreator(this)
-
- .append("id", this.getId())
- .append("new", this.isNew())
- .append("lastName", this.getLastName())
- .append("firstName", this.getFirstName())
- .append("address", this.address)
- .append("city", this.city)
- .append("telephone", this.telephone)
- .toString();
- }
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.validation.constraints.Digits;
+
+import org.hibernate.validator.constraints.NotEmpty;
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+import org.springframework.core.style.ToStringCreator;
+import org.springframework.samples.kidclinic.model.Person;
+
+/**
+ * Simple JavaBean domain object representing an parent.
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ * @author Michael Isvy
+ */
+@Entity
+@Table(name = "parents")
+public class Parent extends Person {
+ @Column(name = "address")
+ @NotEmpty
+ private String address;
+
+ @Column(name = "city")
+ @NotEmpty
+ private String city;
+
+ @Column(name = "telephone")
+ @NotEmpty
+ @Digits(fraction = 0, integer = 10)
+ private String telephone;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent")
+ private Set kids;
+
+
+ public String getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getCity() {
+ return this.city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getTelephone() {
+ return this.telephone;
+ }
+
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+ protected Set getKidsInternal() {
+ if (this.kids == null) {
+ this.kids = new HashSet<>();
+ }
+ return this.kids;
+ }
+
+ protected void setKidsInternal(Set kids) {
+ this.kids = kids;
+ }
+
+ public List getKids() {
+ List sortedKids = new ArrayList<>(getKidsInternal());
+ PropertyComparator.sort(sortedKids, new MutableSortDefinition("name", true, true));
+ return Collections.unmodifiableList(sortedKids);
+ }
+
+ public void addKid(Kid kid) {
+ if (kid.isNew()) {
+ getKidsInternal().add(kid);
+ }
+ kid.setParent(this);
+ }
+
+ /**
+ * Return the Kid with the given name, or null if none found for this Parent.
+ *
+ * @param name to test
+ * @return true if kid name is already in use
+ */
+ public Kid getKid(String name) {
+ return getKid(name, false);
+ }
+
+ /**
+ * Return the Kid with the given name, or null if none found for this Kid.
+ *
+ * @param name to test
+ * @return true if kid name is already in use
+ */
+ public Kid getKid(String name, boolean ignoreNew) {
+ name = name.toLowerCase();
+ for (Kid kid : getKidsInternal()) {
+ if (!ignoreNew || !kid.isNew()) {
+ String compName = kid.getName();
+ compName = compName.toLowerCase();
+ if (compName.equals(name)) {
+ return kid;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringCreator(this)
+
+ .append("id", this.getId())
+ .append("new", this.isNew())
+ .append("lastName", this.getLastName())
+ .append("firstName", this.getFirstName())
+ .append("address", this.address)
+ .append("city", this.city)
+ .append("telephone", this.telephone)
+ .toString();
+ }
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/ParentController.java b/src/main/java/org/springframework/samples/kidclinic/parent/ParentController.java
index 71d0c1243..9c94b46ab 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/ParentController.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/ParentController.java
@@ -1,136 +1,136 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.Collection;
-import java.util.Map;
-
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.servlet.ModelAndView;
-
-/**
- * @author Juergen Hoeller
- * @author Ken Krebs
- * @author Arjen Poutsma
- * @author Michael Isvy
- */
-@Controller
-class ParentController {
-
- private static final String VIEWS_PARENT_CREATE_OR_UPDATE_FORM = "parents/createOrUpdateParentForm";
- private final ParentRepository parents;
-
-
- @Autowired
- public ParentController(ParentRepository clinicService) {
- this.parents = clinicService;
- }
-
- @InitBinder
- public void setAllowedFields(WebDataBinder dataBinder) {
- dataBinder.setDisallowedFields("id");
- }
-
- @RequestMapping(value = "/parents/new", method = RequestMethod.GET)
- public String initCreationForm(Map model) {
- Parent parent = new Parent();
- model.put("parent", parent);
- return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
- }
-
- @RequestMapping(value = "/parents/new", method = RequestMethod.POST)
- public String processCreationForm(@Valid Parent parent, BindingResult result) {
- if (result.hasErrors()) {
- return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
- } else {
- this.parents.save(parent);
- return "redirect:/parents/" + parent.getId();
- }
- }
-
- @RequestMapping(value = "/parents/find", method = RequestMethod.GET)
- public String initFindForm(Map model) {
- model.put("parent", new Parent());
- return "parents/findParents";
- }
-
- @RequestMapping(value = "/parents", method = RequestMethod.GET)
- public String processFindForm(Parent parent, BindingResult result, Map model) {
-
- // allow parameterless GET request for /parents to return all records
- if (parent.getLastName() == null) {
- parent.setLastName(""); // empty string signifies broadest possible search
- }
-
- // find parents by last name
- Collection results = this.parents.findByLastName(parent.getLastName());
- if (results.isEmpty()) {
- // no parents found
- result.rejectValue("lastName", "notFound", "not found");
- return "parents/findParents";
- } else if (results.size() == 1) {
- // 1 parent found
- parent = results.iterator().next();
- return "redirect:/parents/" + parent.getId();
- } else {
- // multiple parents found
- model.put("selections", results);
- return "parents/parentsList";
- }
- }
-
- @RequestMapping(value = "/parents/{parentId}/edit", method = RequestMethod.GET)
- public String initUpdateParentForm(@PathVariable("parentId") int parentId, Model model) {
- Parent parent = this.parents.findById(parentId);
- model.addAttribute(parent);
- return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
- }
-
- @RequestMapping(value = "/parents/{parentId}/edit", method = RequestMethod.POST)
- public String processUpdateParentForm(@Valid Parent parent, BindingResult result, @PathVariable("parentId") int parentId) {
- if (result.hasErrors()) {
- return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
- } else {
- parent.setId(parentId);
- this.parents.save(parent);
- return "redirect:/parents/{parentId}";
- }
- }
-
- /**
- * Custom handler for displaying an parent.
- *
- * @param parentId the ID of the parent to display
- * @return a ModelMap with the model attributes for the view
- */
- @RequestMapping("/parents/{parentId}")
- public ModelAndView showParent(@PathVariable("parentId") int parentId) {
- ModelAndView mav = new ModelAndView("parents/parentDetails");
- mav.addObject(this.parents.findById(parentId));
- return mav;
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.Collection;
+import java.util.Map;
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * @author Juergen Hoeller
+ * @author Ken Krebs
+ * @author Arjen Poutsma
+ * @author Michael Isvy
+ */
+@Controller
+class ParentController {
+
+ private static final String VIEWS_PARENT_CREATE_OR_UPDATE_FORM = "parents/createOrUpdateParentForm";
+ private final ParentRepository parents;
+
+
+ @Autowired
+ public ParentController(ParentRepository clinicService) {
+ this.parents = clinicService;
+ }
+
+ @InitBinder
+ public void setAllowedFields(WebDataBinder dataBinder) {
+ dataBinder.setDisallowedFields("id");
+ }
+
+ @RequestMapping(value = "/parents/new", method = RequestMethod.GET)
+ public String initCreationForm(Map model) {
+ Parent parent = new Parent();
+ model.put("parent", parent);
+ return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
+ }
+
+ @RequestMapping(value = "/parents/new", method = RequestMethod.POST)
+ public String processCreationForm(@Valid Parent parent, BindingResult result) {
+ if (result.hasErrors()) {
+ return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
+ } else {
+ this.parents.save(parent);
+ return "redirect:/parents/" + parent.getId();
+ }
+ }
+
+ @RequestMapping(value = "/parents/find", method = RequestMethod.GET)
+ public String initFindForm(Map model) {
+ model.put("parent", new Parent());
+ return "parents/findParents";
+ }
+
+ @RequestMapping(value = "/parents", method = RequestMethod.GET)
+ public String processFindForm(Parent parent, BindingResult result, Map model) {
+
+ // allow parameterless GET request for /parents to return all records
+ if (parent.getLastName() == null) {
+ parent.setLastName(""); // empty string signifies broadest possible search
+ }
+
+ // find parents by last name
+ Collection results = this.parents.findByLastName(parent.getLastName());
+ if (results.isEmpty()) {
+ // no parents found
+ result.rejectValue("lastName", "notFound", "not found");
+ return "parents/findParents";
+ } else if (results.size() == 1) {
+ // 1 parent found
+ parent = results.iterator().next();
+ return "redirect:/parents/" + parent.getId();
+ } else {
+ // multiple parents found
+ model.put("selections", results);
+ return "parents/parentsList";
+ }
+ }
+
+ @RequestMapping(value = "/parents/{parentId}/edit", method = RequestMethod.GET)
+ public String initUpdateParentForm(@PathVariable("parentId") int parentId, Model model) {
+ Parent parent = this.parents.findById(parentId);
+ model.addAttribute(parent);
+ return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
+ }
+
+ @RequestMapping(value = "/parents/{parentId}/edit", method = RequestMethod.POST)
+ public String processUpdateParentForm(@Valid Parent parent, BindingResult result, @PathVariable("parentId") int parentId) {
+ if (result.hasErrors()) {
+ return VIEWS_PARENT_CREATE_OR_UPDATE_FORM;
+ } else {
+ parent.setId(parentId);
+ this.parents.save(parent);
+ return "redirect:/parents/{parentId}";
+ }
+ }
+
+ /**
+ * Custom handler for displaying an parent.
+ *
+ * @param parentId the ID of the parent to display
+ * @return a ModelMap with the model attributes for the view
+ */
+ @RequestMapping("/parents/{parentId}")
+ public ModelAndView showParent(@PathVariable("parentId") int parentId) {
+ ModelAndView mav = new ModelAndView("parents/parentDetails");
+ mav.addObject(this.parents.findById(parentId));
+ return mav;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/ParentRepository.java b/src/main/java/org/springframework/samples/kidclinic/parent/ParentRepository.java
index 431abba96..32b281b1e 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/ParentRepository.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/ParentRepository.java
@@ -1,63 +1,63 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.Collection;
-
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.Repository;
-import org.springframework.data.repository.query.Param;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Repository class for Parent domain objects All method names are compliant with Spring Data naming
- * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation
- *
- * @author Ken Krebs
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @author Michael Isvy
- */
-public interface ParentRepository extends Repository {
-
- /**
- * Retrieve {@link Parent}s from the data store by last name, returning all parents
- * whose last name starts with the given name.
- * @param lastName Value to search for
- * @return a Collection of matching {@link Parent}s (or an empty Collection if none
- * found)
- */
- @Query("SELECT DISTINCT parent FROM Parent parent left join fetch parent.kids WHERE parent.lastName LIKE :lastName%")
- @Transactional(readOnly = true)
- Collection findByLastName(@Param("lastName") String lastName);
-
- /**
- * Retrieve an {@link Parent} from the data store by id.
- * @param id the id to search for
- * @return the {@link Parent} if found
- */
- @Query("SELECT parent FROM Parent parent left join fetch parent.kids WHERE parent.id =:id")
- @Transactional(readOnly = true)
- Parent findById(@Param("id") Integer id);
-
- /**
- * Save an {@link Parent} to the data store, either inserting or updating it.
- * @param owner the {@link Parent} to save
- */
- void save(Parent parent);
-
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.Collection;
+
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.Repository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Repository class for Parent domain objects All method names are compliant with Spring Data naming
+ * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation
+ *
+ * @author Ken Krebs
+ * @author Juergen Hoeller
+ * @author Sam Brannen
+ * @author Michael Isvy
+ */
+public interface ParentRepository extends Repository {
+
+ /**
+ * Retrieve {@link Parent}s from the data store by last name, returning all parents
+ * whose last name starts with the given name.
+ * @param lastName Value to search for
+ * @return a Collection of matching {@link Parent}s (or an empty Collection if none
+ * found)
+ */
+ @Query("SELECT DISTINCT parent FROM Parent parent left join fetch parent.kids WHERE parent.lastName LIKE :lastName%")
+ @Transactional(readOnly = true)
+ Collection findByLastName(@Param("lastName") String lastName);
+
+ /**
+ * Retrieve an {@link Parent} from the data store by id.
+ * @param id the id to search for
+ * @return the {@link Parent} if found
+ */
+ @Query("SELECT parent FROM Parent parent left join fetch parent.kids WHERE parent.id =:id")
+ @Transactional(readOnly = true)
+ Parent findById(@Param("id") Integer id);
+
+ /**
+ * Save an {@link Parent} to the data store, either inserting or updating it.
+ * @param owner the {@link Parent} to save
+ */
+ void save(Parent parent);
+
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/parent/VisitController.java b/src/main/java/org/springframework/samples/kidclinic/parent/VisitController.java
index f48d8ecaf..f63a2debc 100644
--- a/src/main/java/org/springframework/samples/kidclinic/parent/VisitController.java
+++ b/src/main/java/org/springframework/samples/kidclinic/parent/VisitController.java
@@ -1,95 +1,95 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.samples.kidclinic.parent;
-
-import java.util.Map;
-
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.samples.kidclinic.visit.Visit;
-import org.springframework.samples.kidclinic.visit.VisitRepository;
-import org.springframework.stereotype.Controller;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-/**
- * @author Juergen Hoeller
- * @author Ken Krebs
- * @author Arjen Poutsma
- * @author Michael Isvy
- * @author Dave Syer
- */
-@Controller
-class VisitController {
-
- private final VisitRepository visits;
- private final KidRepository kids;
-
-
- @Autowired
- public VisitController(VisitRepository visits, KidRepository kids) {
- this.visits = visits;
- this.kids = kids;
- }
-
- @InitBinder
- public void setAllowedFields(WebDataBinder dataBinder) {
- dataBinder.setDisallowedFields("id");
- }
-
- /**
- * Called before each and every @RequestMapping annotated method.
- * 2 goals:
- * - Make sure we always have fresh data
- * - Since we do not use the session scope, make sure that Kid object always has an id
- * (Even though id is not part of the form fields)
- *
- * @param kidId
- * @return Kid
- */
- @ModelAttribute("visit")
- public Visit loadKidWithVisit(@PathVariable("kidId") int kidId, Map model) {
- Kid kid = this.kids.findById(kidId);
- model.put("kid", kid);
- Visit visit = new Visit();
- kid.addVisit(visit);
- return visit;
- }
-
- // Spring MVC calls method loadKidWithVisit(...) before initNewVisitForm is called
- @RequestMapping(value = "/parents/*/kids/{kidId}/visits/new", method = RequestMethod.GET)
- public String initNewVisitForm(@PathVariable("kidId") int kidId, Map model) {
- return "kids/createOrUpdateVisitForm";
- }
-
- // Spring MVC calls method loadKidWithVisit(...) before processNewVisitForm is called
- @RequestMapping(value = "/parents/{parentId}/kids/{kidId}/visits/new", method = RequestMethod.POST)
- public String processNewVisitForm(@Valid Visit visit, BindingResult result) {
- if (result.hasErrors()) {
- return "kids/createOrUpdateVisitForm";
- } else {
- this.visits.save(visit);
- return "redirect:/parents/{parentId}";
- }
- }
-
-}
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.kidclinic.parent;
+
+import java.util.Map;
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.samples.kidclinic.visit.Visit;
+import org.springframework.samples.kidclinic.visit.VisitRepository;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * @author Juergen Hoeller
+ * @author Ken Krebs
+ * @author Arjen Poutsma
+ * @author Michael Isvy
+ * @author Dave Syer
+ */
+@Controller
+class VisitController {
+
+ private final VisitRepository visits;
+ private final KidRepository kids;
+
+
+ @Autowired
+ public VisitController(VisitRepository visits, KidRepository kids) {
+ this.visits = visits;
+ this.kids = kids;
+ }
+
+ @InitBinder
+ public void setAllowedFields(WebDataBinder dataBinder) {
+ dataBinder.setDisallowedFields("id");
+ }
+
+ /**
+ * Called before each and every @RequestMapping annotated method.
+ * 2 goals:
+ * - Make sure we always have fresh data
+ * - Since we do not use the session scope, make sure that Kid object always has an id
+ * (Even though id is not part of the form fields)
+ *
+ * @param kidId
+ * @return Kid
+ */
+ @ModelAttribute("visit")
+ public Visit loadKidWithVisit(@PathVariable("kidId") int kidId, Map model) {
+ Kid kid = this.kids.findById(kidId);
+ model.put("kid", kid);
+ Visit visit = new Visit();
+ kid.addVisit(visit);
+ return visit;
+ }
+
+ // Spring MVC calls method loadKidWithVisit(...) before initNewVisitForm is called
+ @RequestMapping(value = "/parents/*/kids/{kidId}/visits/new", method = RequestMethod.GET)
+ public String initNewVisitForm(@PathVariable("kidId") int kidId, Map model) {
+ return "kids/createOrUpdateVisitForm";
+ }
+
+ // Spring MVC calls method loadKidWithVisit(...) before processNewVisitForm is called
+ @RequestMapping(value = "/parents/{parentId}/kids/{kidId}/visits/new", method = RequestMethod.POST)
+ public String processNewVisitForm(@Valid Visit visit, BindingResult result) {
+ if (result.hasErrors()) {
+ return "kids/createOrUpdateVisitForm";
+ } else {
+ this.visits.save(visit);
+ return "redirect:/parents/{parentId}";
+ }
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/kidclinic/system/CacheConfig.java b/src/main/java/org/springframework/samples/kidclinic/system/CacheConfig.java
index a719197bd..c071553fe 100755
--- a/src/main/java/org/springframework/samples/kidclinic/system/CacheConfig.java
+++ b/src/main/java/org/springframework/samples/kidclinic/system/CacheConfig.java
@@ -1,32 +1,32 @@
-package org.springframework.samples.kidclinic.system;
-
-import javax.cache.configuration.Configuration;
-import javax.cache.configuration.MutableConfiguration;
-
-import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Profile;
-
-/**
- * Cache could be disabled in unit test.
- */
-@org.springframework.context.annotation.Configuration
-@EnableCaching
-@Profile("production")
-class CacheConfig {
-
- @Bean
- public JCacheManagerCustomizer cacheManagerCustomizer() {
- return cm -> {
- Configuration