From 6b2e8696bfce59e8451cd13735689c2e595c61ed Mon Sep 17 00:00:00 2001 From: Austin-Mills Date: Mon, 12 Jun 2017 10:17:12 -0400 Subject: [PATCH 1/5] hello my love From 2e3fb40303b4c6cb6a5722bf42b840aa61771368 Mon Sep 17 00:00:00 2001 From: Sasank Vishnubhatla Date: Mon, 12 Jun 2017 11:09:53 -0400 Subject: [PATCH 2/5] updated README.md --- readme.md | 104 +++--------------------------------------------------- 1 file changed, 4 insertions(+), 100 deletions(-) diff --git a/readme.md b/readme.md index ac30d6392..56a6639cb 100644 --- a/readme.md +++ b/readme.md @@ -1,105 +1,9 @@ -# Spring PetClinic Sample Application [![Build Status](https://travis-ci.org/spring-projects/spring-petclinic.png?branch=master)](https://travis-ci.org/spring-projects/spring-petclinic/) +# Spring KidClinic Sample Application -## Understanding the Spring Petclinic application with a few diagrams -See the presentation here - -## Running petclinic locally +## Running kidclinic locally ``` - git clone https://github.com/spring-projects/spring-petclinic.git - cd spring-petclinic + cd kidclinic ./mvnw spring-boot:run ``` -You can then access petclinic here: http://localhost:8080/ - -petclinic-screenshot - -## In case you find a bug/suggested improvement for Spring Petclinic -Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues - - -## Database configuration - -In its default configuration, Petclinic uses an in-memory database (HSQLDB) which -gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed. -Note that whenever the database type is changed, the data-access.properties file needs to be updated and the mysql-connector-java artifact from the pom.xml needs to be uncommented. - -You could start a MySql database with docker: - -``` -docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8 -``` - -## Working with Petclinic in Eclipse/STS - -### prerequisites -The following items should be installed in your system: -* Maven 3 (http://www.sonatype.com/books/mvnref-book/reference/installation.html) -* git command line tool (https://help.github.com/articles/set-up-git) -* Eclipse with the m2e plugin (m2e is installed by default when using the STS (http://www.springsource.org/sts) distribution of Eclipse) - -Note: when m2e is available, there is an m2 icon in Help -> About dialog. -If m2e is not there, just follow the install process here: http://eclipse.org/m2e/download/ - - -### Steps: - -1) In the command line -``` -git clone https://github.com/spring-projects/spring-petclinic.git -``` -2) Inside Eclipse -``` -File -> Import -> Maven -> Existing Maven project -``` - - -## Looking for something in particular? - -|Spring Boot Configuration | Class or Java property files | -|--------------------------|---| -|The Main Class | [PetClinicApplication](https://github.com/spring-projects/spring-petclinic/blob/master/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java) | -|Properties Files | [application.properties](https://github.com/spring-projects/spring-petclinic/blob/master/src/main/resources) | -|Caching | [CacheConfig](https://github.com/spring-projects/spring-petclinic/blob/master/src/main/java/org/springframework/samples/petclinic/system/CacheConfig.java) | - -## Interesting Spring Petclinic branches and forks - -The Spring Petclinic master branch in the main -[spring-projects](https://github.com/spring-projects/spring-petclinic) -GitHub org is the "canonical" implementation, currently based on -Spring Boot and Thymeleaf. There are quite a few forks in a special -GitHub org [spring-petclinic](https://github.com/spring-petclinic). If -you have a special interest in a different technology stack that could -be used to implement the Pet Clinic then please join the community -there. - -| Link | Main technologies | -|----------------|-------------------| -| [spring-framework-petclinic](https://github.com/spring-petclinic/spring-framework-petclinic) | Spring Framework XML configuration, JSP pages, 3 persistence layers: JDBC, JPA and Spring Data JPA | -| [javaconfig branch](https://github.com/spring-petclinic/spring-framework-petclinic/tree/javaconfig) | Same frameworks as the [spring-framework-petclinic](https://github.com/spring-petclinic/spring-framework-petclinic) but with Java Configuration instead of XML | -| [spring-petclinic-angular](https://github.com/spring-petclinic/spring-petclinic-angularjs) | AngularJS 1.x, Spring Boot and Spring Data JPA | -| [spring-petclinic-microservices](https://github.com/spring-petclinic/spring-petclinic-microservices) | Distributed version of Spring Petclinic built with Spring Cloud | -| [spring-petclinic-reactjs](https://github.com/spring-petclinic/spring-petclinic-reactjs) | ReactJS (with TypeScript) and Spring Boot | - - -## Interaction with other open source projects - -One of the best parts about working on the Spring Petclinic application is that we have the opportunity to work in direct contact with many Open Source projects. We found some bugs/suggested improvements on various topics such as Spring, Spring Data, Bean Validation and even Eclipse! In many cases, they've been fixed/implemented in just a few days. -Here is a list of them: - -| Name | Issue | -|------|-------| -| Spring JDBC: simplify usage of NamedParameterJdbcTemplate | [SPR-10256](https://jira.springsource.org/browse/SPR-10256) and [SPR-10257](https://jira.springsource.org/browse/SPR-10257) | -| Bean Validation / Hibernate Validator: simplify Maven dependencies and backward compatibility |[HV-790](https://hibernate.atlassian.net/browse/HV-790) and [HV-792](https://hibernate.atlassian.net/browse/HV-792) | -| Spring Data: provide more flexibility when working with JPQL queries | [DATAJPA-292](https://jira.springsource.org/browse/DATAJPA-292) | - - -# Contributing - -The [issue tracker](https://github.com/spring-projects/spring-petclinic/issues) is the preferred channel for bug reports, features requests and submitting pull requests. - -For pull requests, editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at . - - - - +You can then access kidclinic here: http://localhost:8080/ \ No newline at end of file From 59fe4c1984322895a315d4c8637b2b8414ca7c08 Mon Sep 17 00:00:00 2001 From: Sasank Vishnubhatla Date: Mon, 12 Jun 2017 11:47:23 -0400 Subject: [PATCH 3/5] Test file with GitKracken --- text.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 text.txt diff --git a/text.txt b/text.txt new file mode 100644 index 000000000..a465ddff2 --- /dev/null +++ b/text.txt @@ -0,0 +1 @@ +austin messed up From a217213d5ed8f499698c8e097bd501ff13863907 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Tue, 13 Jun 2017 17:06:40 +0000 Subject: [PATCH 4/5] fixed child display error --- .../samples/kidclinic/parent/ParentController.java | 2 +- .../resources/templates/kids/createOrUpdateKidForm.html | 4 ++-- src/main/resources/templates/parents/parentDetails.html | 6 +++--- update.sh | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) 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 8770d2977..71d0c1243 100644 --- a/src/main/java/org/springframework/samples/kidclinic/parent/ParentController.java +++ b/src/main/java/org/springframework/samples/kidclinic/parent/ParentController.java @@ -67,7 +67,7 @@ class ParentController { return VIEWS_PARENT_CREATE_OR_UPDATE_FORM; } else { this.parents.save(parent); - return "redirect:/parent/" + parent.getId(); + return "redirect:/parents/" + parent.getId(); } } diff --git a/src/main/resources/templates/kids/createOrUpdateKidForm.html b/src/main/resources/templates/kids/createOrUpdateKidForm.html index 27502e5d3..fda0a0594 100644 --- a/src/main/resources/templates/kids/createOrUpdateKidForm.html +++ b/src/main/resources/templates/kids/createOrUpdateKidForm.html @@ -21,7 +21,7 @@ + th:replace="~{fragments/selectField :: select ('Gender', 'gender', ${gender})}" />
@@ -35,4 +35,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/templates/parents/parentDetails.html b/src/main/resources/templates/parents/parentDetails.html index 86b7cd420..6670667f0 100644 --- a/src/main/resources/templates/parents/parentDetails.html +++ b/src/main/resources/templates/parents/parentDetails.html @@ -9,7 +9,7 @@

Parent Information

- +
@@ -48,7 +48,7 @@
Birth Date
-
Type
+
Gender
@@ -80,4 +80,4 @@ - \ No newline at end of file + diff --git a/update.sh b/update.sh index 2547f5b20..00740be2c 100755 --- a/update.sh +++ b/update.sh @@ -1 +1 @@ -./kill.sh && git pull && ./run.sh & +./kill.sh && git pull origin dev && ./run.sh & From d9772eb4b4d3ed62bbfa5332e6630f5b63247618 Mon Sep 17 00:00:00 2001 From: Sasank Vishnubhatla Date: Wed, 14 Jun 2017 16:57:34 -0400 Subject: [PATCH 5/5] fixed everything with running errors --- .editorconfig | 24 +- .gitignore | 18 +- .mvn/wrapper/maven-wrapper.properties | 2 +- .springBeans | 40 +- .travis.yml | 4 +- docker-compose.yml | 16 +- pom.xml | 458 +- readme.md | 16 +- sonar-project.properties | 24 +- .../kidclinic/KidClinicApplication.java | 70 +- .../samples/kidclinic/doctor/Doctor.java | 158 +- .../kidclinic/doctor/DoctorController.java | 120 +- .../kidclinic/doctor/DoctorRepository.java | 92 +- .../samples/kidclinic/doctor/Doctors.java | 86 +- .../samples/kidclinic/doctor/Specialty.java | 68 +- .../samples/kidclinic/model/BaseEntity.java | 100 +- .../samples/kidclinic/model/NamedEntity.java | 96 +- .../samples/kidclinic/model/Person.java | 110 +- .../samples/kidclinic/model/package-info.java | 10 +- .../samples/kidclinic/parent/Kid.java | 234 +- .../kidclinic/parent/KidController.java | 232 +- .../samples/kidclinic/parent/KidGender.java | 62 +- .../kidclinic/parent/KidGenderFormatter.java | 130 +- .../kidclinic/parent/KidRepository.java | 116 +- .../kidclinic/parent/KidValidator.java | 128 +- .../samples/kidclinic/parent/Parent.java | 312 +- .../kidclinic/parent/ParentController.java | 272 +- .../kidclinic/parent/ParentRepository.java | 126 +- .../kidclinic/parent/VisitController.java | 190 +- .../samples/kidclinic/system/CacheConfig.java | 64 +- .../kidclinic/system/CrashController.java | 76 +- .../kidclinic/system/WelcomeController.java | 28 +- .../samples/kidclinic/visit/Visit.java | 248 +- .../kidclinic/visit/VisitRepository.java | 90 +- src/main/less/header.less | 156 +- src/main/less/petclinic.less | 970 +- src/main/less/responsive.less | 98 +- src/main/less/typography.less | 120 +- .../resources/application-mysql.properties | 12 +- src/main/resources/application.properties | 52 +- src/main/resources/banner.txt | 30 +- src/main/resources/db/hsqldb/data.sql | 100 +- src/main/resources/db/hsqldb/schema.sql | 128 +- src/main/resources/db/mysql/data.sql | 98 +- .../db/mysql/petclinic_db_setup_mysql.txt | 34 +- src/main/resources/db/mysql/schema.sql | 130 +- .../resources/messages/messages.properties | 16 +- .../resources/messages/messages_de.properties | 16 +- .../resources/fonts/montserrat-webfont.svg | 2564 +-- .../resources/fonts/varela_round-webfont.svg | 15748 ++++++++-------- .../templates/doctors/doctorList.html | 56 +- src/main/resources/templates/error.html | 20 +- .../templates/fragments/inputField.html | 52 +- .../resources/templates/fragments/layout.html | 216 +- .../templates/fragments/selectField.html | 56 +- .../templates/kids/createOrUpdateKidForm.html | 76 +- .../kids/createOrUpdateVisitForm.html | 120 +- .../parents/createOrUpdateParentForm.html | 60 +- .../templates/parents/findParents.html | 70 +- .../templates/parents/parentDetails.html | 166 +- .../templates/parents/parentsList.html | 66 +- src/main/resources/templates/reviews.html | 20 +- src/main/resources/templates/welcome.html | 282 +- src/main/wro/wro.properties | 6 +- src/main/wro/wro.xml | 12 +- .../petclinic/model/ValidatorTests.java | 90 +- .../petclinic/owner/OwnerControllerTests.java | 358 +- .../petclinic/owner/PetControllerTests.java | 254 +- .../owner/PetTypeFormatterTests.java | 160 +- .../petclinic/owner/VisitControllerTests.java | 150 +- .../petclinic/service/ClinicServiceTests.java | 412 +- .../petclinic/service/EntityUtils.java | 108 +- .../system/CrashControllerTests.java | 76 +- .../system/ProductionConfigurationTests.java | 46 +- .../petclinic/vet/VetControllerTests.java | 164 +- .../samples/petclinic/vet/VetTests.java | 86 +- src/test/jmeter/petclinic_test_plan.jmx | 822 +- text.txt | 2 +- update.sh | 2 +- 79 files changed, 14050 insertions(+), 14050 deletions(-) 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 cacheConfiguration = createCacheConfiguration(); - cm.createCache("doctors", cacheConfiguration); - }; - } - - private Configuration createCacheConfiguration() { - // Create a cache using infinite heap. A real application will want to use an - // implementation dependent configuration that will better fit your needs - return new MutableConfiguration<>().setStatisticsEnabled(true); - } -} +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 cacheConfiguration = createCacheConfiguration(); + cm.createCache("doctors", cacheConfiguration); + }; + } + + private Configuration createCacheConfiguration() { + // Create a cache using infinite heap. A real application will want to use an + // implementation dependent configuration that will better fit your needs + return new MutableConfiguration<>().setStatisticsEnabled(true); + } +} diff --git a/src/main/java/org/springframework/samples/kidclinic/system/CrashController.java b/src/main/java/org/springframework/samples/kidclinic/system/CrashController.java index d1c7589fd..3290c14f3 100644 --- a/src/main/java/org/springframework/samples/kidclinic/system/CrashController.java +++ b/src/main/java/org/springframework/samples/kidclinic/system/CrashController.java @@ -1,38 +1,38 @@ -/* - * 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.system; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -/** - * Controller used to showcase what happens when an exception is thrown - * - * @author Michael Isvy - *

- * Also see how a view that resolves to "error" has been added ("error.html"). - */ -@Controller -class CrashController { - - @RequestMapping(value = "/oops", method = RequestMethod.GET) - public String triggerException() { - throw new RuntimeException( - "Expected: controller used to showcase what " + "happens when an exception is thrown"); - } - -} +/* + * 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.system; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * Controller used to showcase what happens when an exception is thrown + * + * @author Michael Isvy + *

+ * Also see how a view that resolves to "error" has been added ("error.html"). + */ +@Controller +class CrashController { + + @RequestMapping(value = "/oops", method = RequestMethod.GET) + public String triggerException() { + throw new RuntimeException( + "Expected: controller used to showcase what " + "happens when an exception is thrown"); + } + +} diff --git a/src/main/java/org/springframework/samples/kidclinic/system/WelcomeController.java b/src/main/java/org/springframework/samples/kidclinic/system/WelcomeController.java index fa364619a..9aaddc382 100644 --- a/src/main/java/org/springframework/samples/kidclinic/system/WelcomeController.java +++ b/src/main/java/org/springframework/samples/kidclinic/system/WelcomeController.java @@ -1,14 +1,14 @@ -package org.springframework.samples.kidclinic.system; - - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -class WelcomeController { - - @RequestMapping("/") - public String welcome() { - return "welcome"; - } -} +package org.springframework.samples.kidclinic.system; + + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +class WelcomeController { + + @RequestMapping("/") + public String welcome() { + return "welcome"; + } +} diff --git a/src/main/java/org/springframework/samples/kidclinic/visit/Visit.java b/src/main/java/org/springframework/samples/kidclinic/visit/Visit.java index 1619c928b..30666a627 100755 --- a/src/main/java/org/springframework/samples/kidclinic/visit/Visit.java +++ b/src/main/java/org/springframework/samples/kidclinic/visit/Visit.java @@ -1,124 +1,124 @@ -/* - * 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.visit; - -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -import org.hibernate.validator.constraints.NotEmpty; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.samples.kidclinic.model.BaseEntity; - -/** - * Simple JavaBean domain object representing a visit. - * - * @author Ken Krebs - * @author Dave Syer - */ -@Entity -@Table(name = "visits") -public class Visit extends BaseEntity { - - /** - * Holds value of property date. - */ - @Column(name = "visit_date") - @Temporal(TemporalType.TIMESTAMP) - @DateTimeFormat(pattern = "yyyy/MM/dd") - private Date date; - - /** - * Holds value of property description. - */ - @NotEmpty - @Column(name = "description") - private String description; - - /** - * Holds value of property pet. - */ - @Column(name = "kid_id") - private Integer kidId; - - - /** - * Creates a new instance of Visit for the current date - */ - public Visit() { - this.date = new Date(); - } - - - /** - * Getter for property date. - * - * @return Value of property date. - */ - public Date getDate() { - return this.date; - } - - /** - * Setter for property date. - * - * @param date New value of property date. - */ - public void setDate(Date date) { - this.date = date; - } - - /** - * Getter for property description. - * - * @return Value of property description. - */ - public String getDescription() { - return this.description; - } - - /** - * Setter for property description. - * - * @param description New value of property description. - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Getter for property kid id. - * - * @return Value of property kid id. - */ - public Integer getKidId() { - return this.kidId; - } - - /** - * Setter for property kid id. - * - * @param petId New value of property kid id. - */ - public void setKidId(Integer kidId) { - this.kidId = kidId; - } - -} +/* + * 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.visit; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.hibernate.validator.constraints.NotEmpty; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.samples.kidclinic.model.BaseEntity; + +/** + * Simple JavaBean domain object representing a visit. + * + * @author Ken Krebs + * @author Dave Syer + */ +@Entity +@Table(name = "visits") +public class Visit extends BaseEntity { + + /** + * Holds value of property date. + */ + @Column(name = "visit_date") + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy/MM/dd") + private Date date; + + /** + * Holds value of property description. + */ + @NotEmpty + @Column(name = "description") + private String description; + + /** + * Holds value of property pet. + */ + @Column(name = "kid_id") + private Integer kidId; + + + /** + * Creates a new instance of Visit for the current date + */ + public Visit() { + this.date = new Date(); + } + + + /** + * Getter for property date. + * + * @return Value of property date. + */ + public Date getDate() { + return this.date; + } + + /** + * Setter for property date. + * + * @param date New value of property date. + */ + public void setDate(Date date) { + this.date = date; + } + + /** + * Getter for property description. + * + * @return Value of property description. + */ + public String getDescription() { + return this.description; + } + + /** + * Setter for property description. + * + * @param description New value of property description. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Getter for property kid id. + * + * @return Value of property kid id. + */ + public Integer getKidId() { + return this.kidId; + } + + /** + * Setter for property kid id. + * + * @param petId New value of property kid id. + */ + public void setKidId(Integer kidId) { + this.kidId = kidId; + } + +} diff --git a/src/main/java/org/springframework/samples/kidclinic/visit/VisitRepository.java b/src/main/java/org/springframework/samples/kidclinic/visit/VisitRepository.java index b7e97b37f..aaf3f805c 100644 --- a/src/main/java/org/springframework/samples/kidclinic/visit/VisitRepository.java +++ b/src/main/java/org/springframework/samples/kidclinic/visit/VisitRepository.java @@ -1,45 +1,45 @@ -/* - * 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.visit; - -import java.util.List; - -import org.springframework.dao.DataAccessException; -import org.springframework.data.repository.Repository; -import org.springframework.samples.kidclinic.model.BaseEntity; - -/** - * Repository class for Visit 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 VisitRepository extends Repository { - - /** - * Save a Visit to the data store, either inserting or updating it. - * - * @param visit the Visit to save - * @see BaseEntity#isNew - */ - void save(Visit visit) throws DataAccessException; - - List findByKidId(Integer kidId); - -} +/* + * 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.visit; + +import java.util.List; + +import org.springframework.dao.DataAccessException; +import org.springframework.data.repository.Repository; +import org.springframework.samples.kidclinic.model.BaseEntity; + +/** + * Repository class for Visit 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 VisitRepository extends Repository { + + /** + * Save a Visit to the data store, either inserting or updating it. + * + * @param visit the Visit to save + * @see BaseEntity#isNew + */ + void save(Visit visit) throws DataAccessException; + + List findByKidId(Integer kidId); + +} diff --git a/src/main/less/header.less b/src/main/less/header.less index 781360929..6516a5278 100644 --- a/src/main/less/header.less +++ b/src/main/less/header.less @@ -1,78 +1,78 @@ -.navbar { - //border-top: 4px solid #4286f4; - background-color: transparent; - margin-bottom: 40px; - border-bottom: 0; - border-left: 0; - border-right: 0; - postion: fixed; - top: 0; -} - - -/* -.navbar a.navbar-brand { - background: url("../images/spring-logo-dataflow.png") -1px -1px no-repeat; - margin: 12px 0 6px; - width: 229px; - height: 46px; - display: inline-block; - text-decoration: none; - padding: 0; -} - -.navbar a.navbar-brand span { - display: block; - width: 229px; - height: 46px; - background: url("../images/spring-logo-dataflow.png") -1px -48px no-repeat; - opacity: 0; - -moz-transition: opacity 0.12s ease-in-out; - -webkit-transition: opacity 0.12s ease-in-out; - -o-transition: opacity 0.12s ease-in-out; -} -*/ - -.navbar a:hover.navbar-brand span { - opacity: 1; -} - -.navbar li > a, .navbar-text { - font-family: "montserratregular", sans-serif; - text-shadow: none; - font-size: 14px; - -/* line-height: 14px; */ - padding: 28px 20px; - transition: all 0.15s; - -webkit-transition: all 0.15s; - -moz-transition: all 0.15s; - -o-transition: all 0.15s; - -ms-transition: all 0.15s; -} - -.navbar li > a { - text-transform: uppercase; -} - -.navbar .navbar-text { - margin-top: 0; - margin-bottom: 0; -} -.navbar li:hover > a { - color: #eeeeee; - background-color: #6db33f; -} - -.navbar-toggle { - border-width: 0; - - .icon-bar + .icon-bar { - margin-top: 3px; - } - .icon-bar { - width: 19px; - height: 3px; - } - -} +.navbar { + //border-top: 4px solid #4286f4; + background-color: transparent; + margin-bottom: 40px; + border-bottom: 0; + border-left: 0; + border-right: 0; + postion: fixed; + top: 0; +} + + +/* +.navbar a.navbar-brand { + background: url("../images/spring-logo-dataflow.png") -1px -1px no-repeat; + margin: 12px 0 6px; + width: 229px; + height: 46px; + display: inline-block; + text-decoration: none; + padding: 0; +} + +.navbar a.navbar-brand span { + display: block; + width: 229px; + height: 46px; + background: url("../images/spring-logo-dataflow.png") -1px -48px no-repeat; + opacity: 0; + -moz-transition: opacity 0.12s ease-in-out; + -webkit-transition: opacity 0.12s ease-in-out; + -o-transition: opacity 0.12s ease-in-out; +} +*/ + +.navbar a:hover.navbar-brand span { + opacity: 1; +} + +.navbar li > a, .navbar-text { + font-family: "montserratregular", sans-serif; + text-shadow: none; + font-size: 14px; + +/* line-height: 14px; */ + padding: 28px 20px; + transition: all 0.15s; + -webkit-transition: all 0.15s; + -moz-transition: all 0.15s; + -o-transition: all 0.15s; + -ms-transition: all 0.15s; +} + +.navbar li > a { + text-transform: uppercase; +} + +.navbar .navbar-text { + margin-top: 0; + margin-bottom: 0; +} +.navbar li:hover > a { + color: #eeeeee; + background-color: #6db33f; +} + +.navbar-toggle { + border-width: 0; + + .icon-bar + .icon-bar { + margin-top: 3px; + } + .icon-bar { + width: 19px; + height: 3px; + } + +} diff --git a/src/main/less/petclinic.less b/src/main/less/petclinic.less index c620f2ce4..293656f33 100644 --- a/src/main/less/petclinic.less +++ b/src/main/less/petclinic.less @@ -1,485 +1,485 @@ -/* - * Copyright 2016 the original author or authors. - * - * 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. - */ -@icon-font-path: "../../webjars/bootstrap/fonts/"; - -@spring-green: #4286f4; -@spring-dark-green: #2733ad; -@spring-brown: #34302D; -@spring-grey: #838789; -@spring-light-grey: #f1f1f1; - -@body-bg: transparent; -@text-color: @spring-brown; -@link-color: @spring-dark-green; -@link-hover-color: @spring-dark-green; - -@navbar-default-link-color: @spring-brown; -@navbar-default-link-active-color: @spring-brown; -@navbar-default-link-hover-color: @spring-brown; -@navbar-default-link-hover-bg: @spring-green; -@navbar-default-toggle-icon-bar-bg: @spring-light-grey; -@navbar-default-toggle-hover-bg: transparent; -@navbar-default-link-active-bg: @spring-green; - -@border-radius-base: 0; -@border-radius-large: 0; -@border-radius-small: 0; - -@btn-default-color: @spring-light-grey; -@btn-default-bg: @spring-brown; -@btn-default-border: @spring-green; - -@nav-tabs-active-link-hover-color: @spring-light-grey; -@nav-tabs-active-link-hover-bg: @spring-brown; -@nav-tabs-active-link-hover-border-color: @spring-brown; -@nav-tabs-border-color: @spring-brown; - -@pagination-active-bg: @spring-brown; -@pagination-active-border: @spring-green; -@table-border-color: @spring-brown; - -.table > thead > tr > th { - background-color: lighten(@spring-brown, 3%); - color: @spring-light-grey; -} - -.carousel { - height: 100%; - width: 100%; - overflow:hidden; -} -.carousel .carousel-inner { - height:100%; -} -.carousel .carousel-inner img { - display:block; - object-fit: cover; -} -.mycarousel { - height: 100%; - width: 100%; - overflow:hidden; -} -.navbar-brand { - padding-top: 28px; -} -.table-filter { - background-color: @spring-brown; - padding: 9px 12px; -} - -.nav > li > a { - color: @spring-grey; -} - -.btn-default { - border-width: 2px; - transition: border 0.15s; - -webkit-transition: border 0.15s; - -moz-transition: border 0.15s; - -o-transition: border 0.15s; - -ms-transition: border 0.15s; - - &:hover, - &:focus, - &:active, - &.active, - .open .dropdown-toggle& { - background-color: @spring-brown; - border-color: @spring-brown; - } -} - - -.container .text-muted { - //margin: 20px 0; - width: 100%; - height: 100%; -} - -.container-custom -{ - -margin-right:auto; -margin-left:auto; -text-align:center; -position:fixed; -z-index: 2; -background-color: white; -width: 100%; -color: black; - - - -} - -code { - font-size: 80%; -} - -.xd-container { - margin-top: 15px; - //margin-bottom: 100px; - padding-left: 0px; - padding-right: 0px; - overflow:hidden; - width: 100%; - height: 100%; - //margin-right: -60px; - -} -/////// -.portion { - - - background-position: center center; - background-attachment: fixed; - background-size: cover; - text-align: center; -} -.portion.two { - background-image: url("../images/healthcare.jpg") -} -.portion.four { - background-image: url("../images/healthcare3.jpg") -} -.portion.five{ - background-image: url("../images/healthcare4.jpg") -} -.portion h2 { - color: white; - font-weight: normal; - font-size: 3em; - padding: 2em 0; - margin: 0; - text-shadow: 0 0 10px black; - background: rgba(0,0,0,0.6); -} - -.info { - background: #FFFAF0; - color: #777; - padding: 3em 20%; -} - -.button { - text-align: center; -} -.button a { - display: inline-block; - border: 2px solid #777; - padding: .75em 1.5em; - color: #777; - text-decoration: none; - text-transform: uppercase; - border-radius: 5px; - letter-spacing: .15em; - word-spacing: .25em; - font-weight: bold; - transition: all 0.3s ease-in-out; -} -.button a:hover { - color: #FFFAF0; - background: #777; -} -footer.info { - color: #FFFAF0; - background: #777; - padding: 0 auto; - text-align: center; -} -.cd-top.cd-is-visible { - /* the button becomes visible */ - visibility: visible; - opacity: 1; -} -.cd-top.cd-fade-out { - /* if the user keeps scrolling down, the button is out of focus and becomes less visible */ - opacity: .5; -} - -.return-to-top { - position: fixed; - bottom: 20px; - right: 20px; - background: rgb(0, 0, 0); - background: rgba(0, 0, 0, 0.7); - width: 50px; - height: 50px; - display: block; - text-decoration: none; - -webkit-border-radius: 35px; - -moz-border-radius: 35px; - border-radius: 35px; - display: none; - -webkit-transition: all 0.3s linear; - -moz-transition: all 0.3s ease; - -ms-transition: all 0.3s ease; - -o-transition: all 0.3s ease; - transition: all 0.3s ease; -} -.return-to-top i { - color: #fff; - margin: 0; - position: relative; - left: 16px; - top: 13px; - font-size: 19px; - -webkit-transition: all 0.3s ease; - -moz-transition: all 0.3s ease; - -ms-transition: all 0.3s ease; - -o-transition: all 0.3s ease; - transition: all 0.3s ease; -} -.return-to-top:hover { - background: rgba(0, 0, 0, 0.9); -} -.return-to-top:hover i { - color: #fff; - top: 5px; -} - - - - - - - - - - - - - - -.footcustom{ - - } - -#toTop img { - width: 50px; -} -#toTop img:hover { - cursor: pointer; -} - - -.move { - top: -60px; -} - - - -.movetext { - top: -30px; -} - - -/////// - - - - - - - - - - - - - - -h1 { - margin-bottom: 15px -} -h6{ - width: 100%; - height: 100%; - background-position: center; - -webkit-background-size: cover; - -moz-background-size: cover; - background-size: cover; - -o-background-size: cover; -} -h5{ - padding-top: 40px; -} -.index-page--subtitle { - font-size: 16px; - line-height: 24px; - margin: 0 0 30px; -} - -.form-horizontal button.btn-inverse { - margin-left: 32px; -} - -#job-params-modal .modal-dialog { - width: 100%; - //margin-left:auto; - //margin-right:auto; -} - -[ng-cloak].splash { - display: block !important; -} -[ng-cloak] { - display: none; -} - -.splash { - background: @spring-green; - color: @spring-brown; - display: none; -} - -.error-page { - margin-top: 100px; - text-align: center; -} - -.error-page .error-title { - font-size: 24px; - line-height: 24px; - margin: 30px 0 0; -} - -table td { - vertical-align: middle; -} - -table td .progress { - margin-bottom: 0; -} - -table td.action-column { - width: 1px; -} - -.help-block { - color: lighten(@text-color, 50%); // lighten the text some for contrast -} -//.glyphicon { -// font-size: 20px; -//} -.container-fluid{ - width: 100%; - height:100%; - margin-top: 25px; - padding-left:0px; - padding-right:0px; - //margin-right:-500px; - //margin-left:-30px; -} - - - - - - - -//.navbar.navbar-default .nav-collapse { background-color: #f8f8f8; border-color: #080808; } -.navbar.navbar-inverse .nav-collapse { background-color: #222; border-color: #080808; z-index: 2; } - -.navbar-right {width: 100%; -margin-right:0px;} - - - - - - - -.xd-containers { - font-size: 15px; - width: 100%; -} - -.cluster-view > table td { - vertical-align: top; -} - -.cluster-view .label, .cluster-view .column-block { - display: block; -} - -.cluster-view .input-group-addon { - width: 0%; -} - -.cluster-view { - margin-bottom: 0; -} - -.deployment-status-deployed { - .label-success; -} - -.deployment-status-incomplete { - .label-warning; -} - -.deployment-status-failed { - .label-danger; -} - -.deployment-status-deploying { - .label-info -} -.deployment-status-na { -} - -.container-details-table th { - background-color: lighten(@spring-brown, 3%); - color: @spring-light-grey; -} - -.status-help-content-table td { - color: @spring-brown; -} - -.alert-success { - .alert-variant(fade(@alert-success-bg, 70%); @alert-success-border; @alert-success-text); -} -.alert-info { - .alert-variant(fade(@alert-info-bg, 70%); @alert-info-border; @alert-info-text); -} -.alert-warning { - .alert-variant(fade(@alert-warning-bg, 70%); @alert-warning-border; @alert-warning-text); -} -.alert-danger { - .alert-variant(fade(@alert-danger-bg, 70%); @alert-danger-border; @alert-danger-text); -} - -.myspinner { - animation-name: spinner; - animation-duration: 2s; - animation-iteration-count: infinite; - animation-timing-function: linear; - - -webkit-transform-origin: 49% 50%; - -webkit-animation-name: spinner; - -webkit-animation-duration: 2s; - -webkit-animation-iteration-count: infinite; - -webkit-animation-timing-function: linear; -} - -hr { - border-top: 1px dotted @spring-brown; -} - -@import "typography.less"; -@import "header.less"; -@import "responsive.less"; +/* + * Copyright 2016 the original author or authors. + * + * 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. + */ +@icon-font-path: "../../webjars/bootstrap/fonts/"; + +@spring-green: #4286f4; +@spring-dark-green: #2733ad; +@spring-brown: #34302D; +@spring-grey: #838789; +@spring-light-grey: #f1f1f1; + +@body-bg: transparent; +@text-color: @spring-brown; +@link-color: @spring-dark-green; +@link-hover-color: @spring-dark-green; + +@navbar-default-link-color: @spring-brown; +@navbar-default-link-active-color: @spring-brown; +@navbar-default-link-hover-color: @spring-brown; +@navbar-default-link-hover-bg: @spring-green; +@navbar-default-toggle-icon-bar-bg: @spring-light-grey; +@navbar-default-toggle-hover-bg: transparent; +@navbar-default-link-active-bg: @spring-green; + +@border-radius-base: 0; +@border-radius-large: 0; +@border-radius-small: 0; + +@btn-default-color: @spring-light-grey; +@btn-default-bg: @spring-brown; +@btn-default-border: @spring-green; + +@nav-tabs-active-link-hover-color: @spring-light-grey; +@nav-tabs-active-link-hover-bg: @spring-brown; +@nav-tabs-active-link-hover-border-color: @spring-brown; +@nav-tabs-border-color: @spring-brown; + +@pagination-active-bg: @spring-brown; +@pagination-active-border: @spring-green; +@table-border-color: @spring-brown; + +.table > thead > tr > th { + background-color: lighten(@spring-brown, 3%); + color: @spring-light-grey; +} + +.carousel { + height: 100%; + width: 100%; + overflow:hidden; +} +.carousel .carousel-inner { + height:100%; +} +.carousel .carousel-inner img { + display:block; + object-fit: cover; +} +.mycarousel { + height: 100%; + width: 100%; + overflow:hidden; +} +.navbar-brand { + padding-top: 28px; +} +.table-filter { + background-color: @spring-brown; + padding: 9px 12px; +} + +.nav > li > a { + color: @spring-grey; +} + +.btn-default { + border-width: 2px; + transition: border 0.15s; + -webkit-transition: border 0.15s; + -moz-transition: border 0.15s; + -o-transition: border 0.15s; + -ms-transition: border 0.15s; + + &:hover, + &:focus, + &:active, + &.active, + .open .dropdown-toggle& { + background-color: @spring-brown; + border-color: @spring-brown; + } +} + + +.container .text-muted { + //margin: 20px 0; + width: 100%; + height: 100%; +} + +.container-custom +{ + +margin-right:auto; +margin-left:auto; +text-align:center; +position:fixed; +z-index: 2; +background-color: white; +width: 100%; +color: black; + + + +} + +code { + font-size: 80%; +} + +.xd-container { + margin-top: 15px; + //margin-bottom: 100px; + padding-left: 0px; + padding-right: 0px; + overflow:hidden; + width: 100%; + height: 100%; + //margin-right: -60px; + +} +/////// +.portion { + + + background-position: center center; + background-attachment: fixed; + background-size: cover; + text-align: center; +} +.portion.two { + background-image: url("../images/healthcare.jpg") +} +.portion.four { + background-image: url("../images/healthcare3.jpg") +} +.portion.five{ + background-image: url("../images/healthcare4.jpg") +} +.portion h2 { + color: white; + font-weight: normal; + font-size: 3em; + padding: 2em 0; + margin: 0; + text-shadow: 0 0 10px black; + background: rgba(0,0,0,0.6); +} + +.info { + background: #FFFAF0; + color: #777; + padding: 3em 20%; +} + +.button { + text-align: center; +} +.button a { + display: inline-block; + border: 2px solid #777; + padding: .75em 1.5em; + color: #777; + text-decoration: none; + text-transform: uppercase; + border-radius: 5px; + letter-spacing: .15em; + word-spacing: .25em; + font-weight: bold; + transition: all 0.3s ease-in-out; +} +.button a:hover { + color: #FFFAF0; + background: #777; +} +footer.info { + color: #FFFAF0; + background: #777; + padding: 0 auto; + text-align: center; +} +.cd-top.cd-is-visible { + /* the button becomes visible */ + visibility: visible; + opacity: 1; +} +.cd-top.cd-fade-out { + /* if the user keeps scrolling down, the button is out of focus and becomes less visible */ + opacity: .5; +} + +.return-to-top { + position: fixed; + bottom: 20px; + right: 20px; + background: rgb(0, 0, 0); + background: rgba(0, 0, 0, 0.7); + width: 50px; + height: 50px; + display: block; + text-decoration: none; + -webkit-border-radius: 35px; + -moz-border-radius: 35px; + border-radius: 35px; + display: none; + -webkit-transition: all 0.3s linear; + -moz-transition: all 0.3s ease; + -ms-transition: all 0.3s ease; + -o-transition: all 0.3s ease; + transition: all 0.3s ease; +} +.return-to-top i { + color: #fff; + margin: 0; + position: relative; + left: 16px; + top: 13px; + font-size: 19px; + -webkit-transition: all 0.3s ease; + -moz-transition: all 0.3s ease; + -ms-transition: all 0.3s ease; + -o-transition: all 0.3s ease; + transition: all 0.3s ease; +} +.return-to-top:hover { + background: rgba(0, 0, 0, 0.9); +} +.return-to-top:hover i { + color: #fff; + top: 5px; +} + + + + + + + + + + + + + + +.footcustom{ + + } + +#toTop img { + width: 50px; +} +#toTop img:hover { + cursor: pointer; +} + + +.move { + top: -60px; +} + + + +.movetext { + top: -30px; +} + + +/////// + + + + + + + + + + + + + + +h1 { + margin-bottom: 15px +} +h6{ + width: 100%; + height: 100%; + background-position: center; + -webkit-background-size: cover; + -moz-background-size: cover; + background-size: cover; + -o-background-size: cover; +} +h5{ + padding-top: 40px; +} +.index-page--subtitle { + font-size: 16px; + line-height: 24px; + margin: 0 0 30px; +} + +.form-horizontal button.btn-inverse { + margin-left: 32px; +} + +#job-params-modal .modal-dialog { + width: 100%; + //margin-left:auto; + //margin-right:auto; +} + +[ng-cloak].splash { + display: block !important; +} +[ng-cloak] { + display: none; +} + +.splash { + background: @spring-green; + color: @spring-brown; + display: none; +} + +.error-page { + margin-top: 100px; + text-align: center; +} + +.error-page .error-title { + font-size: 24px; + line-height: 24px; + margin: 30px 0 0; +} + +table td { + vertical-align: middle; +} + +table td .progress { + margin-bottom: 0; +} + +table td.action-column { + width: 1px; +} + +.help-block { + color: lighten(@text-color, 50%); // lighten the text some for contrast +} +//.glyphicon { +// font-size: 20px; +//} +.container-fluid{ + width: 100%; + height:100%; + margin-top: 25px; + padding-left:0px; + padding-right:0px; + //margin-right:-500px; + //margin-left:-30px; +} + + + + + + + +//.navbar.navbar-default .nav-collapse { background-color: #f8f8f8; border-color: #080808; } +.navbar.navbar-inverse .nav-collapse { background-color: #222; border-color: #080808; z-index: 2; } + +.navbar-right {width: 100%; +margin-right:0px;} + + + + + + + +.xd-containers { + font-size: 15px; + width: 100%; +} + +.cluster-view > table td { + vertical-align: top; +} + +.cluster-view .label, .cluster-view .column-block { + display: block; +} + +.cluster-view .input-group-addon { + width: 0%; +} + +.cluster-view { + margin-bottom: 0; +} + +.deployment-status-deployed { + .label-success; +} + +.deployment-status-incomplete { + .label-warning; +} + +.deployment-status-failed { + .label-danger; +} + +.deployment-status-deploying { + .label-info +} +.deployment-status-na { +} + +.container-details-table th { + background-color: lighten(@spring-brown, 3%); + color: @spring-light-grey; +} + +.status-help-content-table td { + color: @spring-brown; +} + +.alert-success { + .alert-variant(fade(@alert-success-bg, 70%); @alert-success-border; @alert-success-text); +} +.alert-info { + .alert-variant(fade(@alert-info-bg, 70%); @alert-info-border; @alert-info-text); +} +.alert-warning { + .alert-variant(fade(@alert-warning-bg, 70%); @alert-warning-border; @alert-warning-text); +} +.alert-danger { + .alert-variant(fade(@alert-danger-bg, 70%); @alert-danger-border; @alert-danger-text); +} + +.myspinner { + animation-name: spinner; + animation-duration: 2s; + animation-iteration-count: infinite; + animation-timing-function: linear; + + -webkit-transform-origin: 49% 50%; + -webkit-animation-name: spinner; + -webkit-animation-duration: 2s; + -webkit-animation-iteration-count: infinite; + -webkit-animation-timing-function: linear; +} + +hr { + border-top: 1px dotted @spring-brown; +} + +@import "typography.less"; +@import "header.less"; +@import "responsive.less"; diff --git a/src/main/less/responsive.less b/src/main/less/responsive.less index d07e80b3f..f01b3b9bc 100644 --- a/src/main/less/responsive.less +++ b/src/main/less/responsive.less @@ -1,49 +1,49 @@ -@media (max-width: 768px) { - .navbar-toggle { - position:absolute; - z-index: 9999; - left:0px; - top:0px; - } - .navbar-collapse {width:100%} - .navbar a.navbar-brand { - display: block; - margin: 0 auto 0 auto; - width: 148px; - height: 50px; - float: none; - background: url("../images/spring-logo-dataflow-mobile.png") 0 center no-repeat; - } - - .homepage-billboard .homepage-subtitle { - font-size: 21px; - line-height: 21px; - } -.floating-custom -{ - -margin-right:auto; -margin-left:auto; -text-align:center; -position:fixed; - -} - .navbar a.navbar-brand span { - display: none; - } - - .navbar { - border-top-width: 0; - } - - .xd-container { - margin-top: 20px; - //margin-bottom: 30px; - } - - .index-page--subtitle { - margin-top: 10px; - margin-bottom: 30px; - } - -} +@media (max-width: 768px) { + .navbar-toggle { + position:absolute; + z-index: 9999; + left:0px; + top:0px; + } + .navbar-collapse {width:100%} + .navbar a.navbar-brand { + display: block; + margin: 0 auto 0 auto; + width: 148px; + height: 50px; + float: none; + background: url("../images/spring-logo-dataflow-mobile.png") 0 center no-repeat; + } + + .homepage-billboard .homepage-subtitle { + font-size: 21px; + line-height: 21px; + } +.floating-custom +{ + +margin-right:auto; +margin-left:auto; +text-align:center; +position:fixed; + +} + .navbar a.navbar-brand span { + display: none; + } + + .navbar { + border-top-width: 0; + } + + .xd-container { + margin-top: 20px; + //margin-bottom: 30px; + } + + .index-page--subtitle { + margin-top: 10px; + margin-bottom: 30px; + } + +} diff --git a/src/main/less/typography.less b/src/main/less/typography.less index 38f9815b5..c64a53dbb 100644 --- a/src/main/less/typography.less +++ b/src/main/less/typography.less @@ -1,60 +1,60 @@ -@font-face { - font-family: 'varela_roundregular'; - - src: url('../fonts/varela_round-webfont.eot'); - src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/varela_round-webfont.woff') format('woff'), - url('../fonts/varela_round-webfont.ttf') format('truetype'), - url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg'); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: 'montserratregular'; - src: url('../fonts/montserrat-webfont.eot'); - src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/montserrat-webfont.woff') format('woff'), - url('../fonts/montserrat-webfont.ttf') format('truetype'), - url('../fonts/montserrat-webfont.svg#montserratregular') format('svg'); - font-weight: normal; - font-style: normal; -} - -body, h1, h2, h3, p, input { - margin: 0; - font-weight: 400; - font-family: "Bookman Old Style"; - color: #0000; -} - -h1 { - font-size: 24px; - line-height: 30px; - font-family: "montserratregular", sans-serif; -} - -h2 { - font-size: 18px; - font-weight: 700; - line-height: 24px; - margin-bottom: 10px; - font-family: "montserratregular", sans-serif; -} - -h3 { - font-size: 16px; - line-height: 24px; - margin-bottom: 10px; - font-weight: 700; -} - -p { - //font-size: 15px; - //line-height: 24px; -} - -strong { - font-weight: 700; - font-family: "montserratregular", sans-serif; -} +@font-face { + font-family: 'varela_roundregular'; + + src: url('../fonts/varela_round-webfont.eot'); + src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'), + url('../fonts/varela_round-webfont.woff') format('woff'), + url('../fonts/varela_round-webfont.ttf') format('truetype'), + url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'montserratregular'; + src: url('../fonts/montserrat-webfont.eot'); + src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'), + url('../fonts/montserrat-webfont.woff') format('woff'), + url('../fonts/montserrat-webfont.ttf') format('truetype'), + url('../fonts/montserrat-webfont.svg#montserratregular') format('svg'); + font-weight: normal; + font-style: normal; +} + +body, h1, h2, h3, p, input { + margin: 0; + font-weight: 400; + font-family: "Bookman Old Style"; + color: #0000; +} + +h1 { + font-size: 24px; + line-height: 30px; + font-family: "montserratregular", sans-serif; +} + +h2 { + font-size: 18px; + font-weight: 700; + line-height: 24px; + margin-bottom: 10px; + font-family: "montserratregular", sans-serif; +} + +h3 { + font-size: 16px; + line-height: 24px; + margin-bottom: 10px; + font-weight: 700; +} + +p { + //font-size: 15px; + //line-height: 24px; +} + +strong { + font-weight: 700; + font-family: "montserratregular", sans-serif; +} diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index fd561fa90..4641d877c 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -1,7 +1,7 @@ -# database init, supports mysql too -database=mysql -spring.datasource.url=jdbc:mysql://localhost/test -spring.datasource.username=root -spring.datasource.password=root - # Uncomment this the first time the app runs +# database init, supports mysql too +database=mysql +spring.datasource.url=jdbc:mysql://localhost/test +spring.datasource.username=root +spring.datasource.password=root + # Uncomment this the first time the app runs # spring.datasource.initialize=true \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fb07c6c50..f5b0385e9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,26 +1,26 @@ -# database init, supports mysql too -database=hsqldb -spring.datasource.schema=classpath*:db/${database}/schema.sql -spring.datasource.data=classpath*:db/${database}/data.sql - -# Web -spring.thymeleaf.mode=HTML - -# JPA -spring.jpa.hibernate.ddl-auto=none - -# Internationalization -spring.messages.basename=messages/messages - -# Actuator / Management -management.contextPath=/manage -# Spring Boot 1.5 makes actuator secure by default -management.security.enabled=false - -# Logging -logging.level.org.springframework=INFO -# logging.level.org.springframework.web=DEBUG -# logging.level.org.springframework.context.annotation=TRACE - -# Active Spring profiles -spring.profiles.active=production +# database init, supports mysql too +database=hsqldb +spring.datasource.schema=classpath*:db/${database}/schema.sql +spring.datasource.data=classpath*:db/${database}/data.sql + +# Web +spring.thymeleaf.mode=HTML + +# JPA +spring.jpa.hibernate.ddl-auto=none + +# Internationalization +spring.messages.basename=messages/messages + +# Actuator / Management +management.contextPath=/manage +# Spring Boot 1.5 makes actuator secure by default +management.security.enabled=false + +# Logging +logging.level.org.springframework=INFO +# logging.level.org.springframework.web=DEBUG +# logging.level.org.springframework.context.annotation=TRACE + +# Active Spring profiles +spring.profiles.active=production diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt index 6225d1208..a3d40b9ea 100644 --- a/src/main/resources/banner.txt +++ b/src/main/resources/banner.txt @@ -1,15 +1,15 @@ - - - |\ _,,,--,,_ - /,`.-'`' ._ \-;;,_ - _______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______ - | | '---''(_/._)-'(_\_) | | | | | | | | | - | _ | ___|_ _| | | | | |_| | | | __ _ _ - | |_| | |___ | | | | | | | | | | \ \ \ \ - | ___| ___| | | | _| |___| | _ | | _| \ \ \ \ - | | | |___ | | | |_| | | | | | | |_ ) ) ) ) - |___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / / - ==================================================================/_/_/_/ - -:: Built with Spring Boot :: ${spring-boot.version} - + + + |\ _,,,--,,_ + /,`.-'`' ._ \-;;,_ + _______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______ + | | '---''(_/._)-'(_\_) | | | | | | | | | + | _ | ___|_ _| | | | | |_| | | | __ _ _ + | |_| | |___ | | | | | | | | | | \ \ \ \ + | ___| ___| | | | _| |___| | _ | | _| \ \ \ \ + | | | |___ | | | |_| | | | | | | |_ ) ) ) ) + |___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / / + ==================================================================/_/_/_/ + +:: Built with Spring Boot :: ${spring-boot.version} + diff --git a/src/main/resources/db/hsqldb/data.sql b/src/main/resources/db/hsqldb/data.sql index 931424f88..12674d1dd 100644 --- a/src/main/resources/db/hsqldb/data.sql +++ b/src/main/resources/db/hsqldb/data.sql @@ -1,50 +1,50 @@ -INSERT INTO doctors VALUES (1, 'James', 'Carter'); -INSERT INTO doctors VALUES (2, 'Helen', 'Leary'); -INSERT INTO doctors VALUES (3, 'Linda', 'Douglas'); -INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega'); -INSERT INTO doctors VALUES (5, 'Henry', 'Stevens'); -INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins'); - -INSERT INTO specialties VALUES (1, 'radiology'); -INSERT INTO specialties VALUES (2, 'surgery'); -INSERT INTO specialties VALUES (3, 'dentistry'); - -INSERT INTO doctor_specialties VALUES (2, 1); -INSERT INTO doctor_specialties VALUES (3, 2); -INSERT INTO doctor_specialties VALUES (3, 3); -INSERT INTO doctor_specialties VALUES (4, 2); -INSERT INTO doctor_specialties VALUES (5, 1); - -INSERT INTO gender VALUES (1, 'male'); -INSERT INTO gender VALUES (2, 'female'); - - -INSERT INTO parents VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); -INSERT INTO parents VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); -INSERT INTO parents VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); -INSERT INTO parents VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); -INSERT INTO parents VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); -INSERT INTO parents VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); -INSERT INTO parents VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); -INSERT INTO parents VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); -INSERT INTO parents VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); -INSERT INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); - -INSERT INTO kids VALUES (1, 'Alyssa', '2000-09-07', 2, 1); -INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2); -INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3); -INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3); -INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4); -INSERT INTO kids VALUES (6, 'Samantha', '2000-01-20', 2, 5); -INSERT INTO kids VALUES (7, 'George', '1995-09-04', 1, 6); -INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6); -INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7); -INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8); -INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9); -INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10); -INSERT INTO kids VALUES (13, 'Conner', '2002-06-08', 1, 10); - -INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot'); -INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot'); -INSERT INTO visits VALUES (3, 8, '2013-01-03', 'cold'); -INSERT INTO visits VALUES (4, 7, '2013-01-04', 'flu'); +INSERT INTO doctors VALUES (1, 'James', 'Carter'); +INSERT INTO doctors VALUES (2, 'Helen', 'Leary'); +INSERT INTO doctors VALUES (3, 'Linda', 'Douglas'); +INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega'); +INSERT INTO doctors VALUES (5, 'Henry', 'Stevens'); +INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins'); + +INSERT INTO specialties VALUES (1, 'radiology'); +INSERT INTO specialties VALUES (2, 'surgery'); +INSERT INTO specialties VALUES (3, 'dentistry'); + +INSERT INTO doctor_specialties VALUES (2, 1); +INSERT INTO doctor_specialties VALUES (3, 2); +INSERT INTO doctor_specialties VALUES (3, 3); +INSERT INTO doctor_specialties VALUES (4, 2); +INSERT INTO doctor_specialties VALUES (5, 1); + +INSERT INTO gender VALUES (1, 'male'); +INSERT INTO gender VALUES (2, 'female'); + + +INSERT INTO parents VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); +INSERT INTO parents VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); +INSERT INTO parents VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); +INSERT INTO parents VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); +INSERT INTO parents VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); +INSERT INTO parents VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); +INSERT INTO parents VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); +INSERT INTO parents VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); +INSERT INTO parents VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); +INSERT INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); + +INSERT INTO kids VALUES (1, 'Alyssa', '2000-09-07', 2, 1); +INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2); +INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3); +INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3); +INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4); +INSERT INTO kids VALUES (6, 'Samantha', '2000-01-20', 2, 5); +INSERT INTO kids VALUES (7, 'George', '1995-09-04', 1, 6); +INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6); +INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7); +INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8); +INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9); +INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10); +INSERT INTO kids VALUES (13, 'Conner', '2002-06-08', 1, 10); + +INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot'); +INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot'); +INSERT INTO visits VALUES (3, 8, '2013-01-03', 'cold'); +INSERT INTO visits VALUES (4, 7, '2013-01-04', 'flu'); diff --git a/src/main/resources/db/hsqldb/schema.sql b/src/main/resources/db/hsqldb/schema.sql index 625038578..084c62ad7 100644 --- a/src/main/resources/db/hsqldb/schema.sql +++ b/src/main/resources/db/hsqldb/schema.sql @@ -1,64 +1,64 @@ -DROP TABLE doctor_specialties IF EXISTS; -DROP TABLE doctors IF EXISTS; -DROP TABLE specialties IF EXISTS; -DROP TABLE visits IF EXISTS; -DROP TABLE kids IF EXISTS; -DROP TABLE gender IF EXISTS; -DROP TABLE parents IF EXISTS; - - -CREATE TABLE doctors ( - id INTEGER IDENTITY PRIMARY KEY, - first_name VARCHAR(30), - last_name VARCHAR(30) -); -CREATE INDEX doctors_last_name ON doctors (last_name); - -CREATE TABLE specialties ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(80) -); -CREATE INDEX specialties_name ON specialties (name); - -CREATE TABLE doctor_specialties ( - doctor_id INTEGER NOT NULL, - specialty_id INTEGER NOT NULL -); -ALTER TABLE doctor_specialties ADD CONSTRAINT fk_doctor_specialties_doctors FOREIGN KEY (doctor_id) REFERENCES doctors (id); -ALTER TABLE doctor_specialties ADD CONSTRAINT fk_doctor_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); - -CREATE TABLE gender ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(80) -); -CREATE INDEX gender_name ON gender (name); - -CREATE TABLE parents ( - id INTEGER IDENTITY PRIMARY KEY, - first_name VARCHAR(30), - last_name VARCHAR_IGNORECASE(30), - address VARCHAR(255), - city VARCHAR(80), - telephone VARCHAR(20) -); -CREATE INDEX parents_last_name ON parents (last_name); - -CREATE TABLE kids ( - id INTEGER IDENTITY PRIMARY KEY, - name VARCHAR(30), - birth_date DATE, - gender_id INTEGER NOT NULL, - parent_id INTEGER NOT NULL -); -ALTER TABLE kids ADD CONSTRAINT fk_kids_parents FOREIGN KEY (parent_id) REFERENCES parents (id); -ALTER TABLE kids ADD CONSTRAINT fk_kids_gender FOREIGN KEY (gender_id) REFERENCES gender (id); -CREATE INDEX kids_name ON kids (name); - -CREATE TABLE visits ( - id INTEGER IDENTITY PRIMARY KEY, - kid_id INTEGER NOT NULL, - visit_date DATE, - description VARCHAR(255) -); -ALTER TABLE visits ADD CONSTRAINT fk_visits_kids FOREIGN KEY (kid_id) REFERENCES kids (id); -CREATE INDEX visits_kid_id ON visits (kid_id); +DROP TABLE doctor_specialties IF EXISTS; +DROP TABLE doctors IF EXISTS; +DROP TABLE specialties IF EXISTS; +DROP TABLE visits IF EXISTS; +DROP TABLE kids IF EXISTS; +DROP TABLE gender IF EXISTS; +DROP TABLE parents IF EXISTS; + + +CREATE TABLE doctors ( + id INTEGER IDENTITY PRIMARY KEY, + first_name VARCHAR(30), + last_name VARCHAR(30) +); +CREATE INDEX doctors_last_name ON doctors (last_name); + +CREATE TABLE specialties ( + id INTEGER IDENTITY PRIMARY KEY, + name VARCHAR(80) +); +CREATE INDEX specialties_name ON specialties (name); + +CREATE TABLE doctor_specialties ( + doctor_id INTEGER NOT NULL, + specialty_id INTEGER NOT NULL +); +ALTER TABLE doctor_specialties ADD CONSTRAINT fk_doctor_specialties_doctors FOREIGN KEY (doctor_id) REFERENCES doctors (id); +ALTER TABLE doctor_specialties ADD CONSTRAINT fk_doctor_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); + +CREATE TABLE gender ( + id INTEGER IDENTITY PRIMARY KEY, + name VARCHAR(80) +); +CREATE INDEX gender_name ON gender (name); + +CREATE TABLE parents ( + id INTEGER IDENTITY PRIMARY KEY, + first_name VARCHAR(30), + last_name VARCHAR_IGNORECASE(30), + address VARCHAR(255), + city VARCHAR(80), + telephone VARCHAR(20) +); +CREATE INDEX parents_last_name ON parents (last_name); + +CREATE TABLE kids ( + id INTEGER IDENTITY PRIMARY KEY, + name VARCHAR(30), + birth_date DATE, + gender_id INTEGER NOT NULL, + parent_id INTEGER NOT NULL +); +ALTER TABLE kids ADD CONSTRAINT fk_kids_parents FOREIGN KEY (parent_id) REFERENCES parents (id); +ALTER TABLE kids ADD CONSTRAINT fk_kids_gender FOREIGN KEY (gender_id) REFERENCES gender (id); +CREATE INDEX kids_name ON kids (name); + +CREATE TABLE visits ( + id INTEGER IDENTITY PRIMARY KEY, + kid_id INTEGER NOT NULL, + visit_date DATE, + description VARCHAR(255) +); +ALTER TABLE visits ADD CONSTRAINT fk_visits_kids FOREIGN KEY (kid_id) REFERENCES kids (id); +CREATE INDEX visits_kid_id ON visits (kid_id); diff --git a/src/main/resources/db/mysql/data.sql b/src/main/resources/db/mysql/data.sql index 1142e93f3..c861ad365 100644 --- a/src/main/resources/db/mysql/data.sql +++ b/src/main/resources/db/mysql/data.sql @@ -1,49 +1,49 @@ -INSERT IGNORE INTO doctors VALUES (1, 'James', 'Carter'); -INSERT IGNORE INTO doctors VALUES (2, 'Helen', 'Leary'); -INSERT IGNORE INTO doctors VALUES (3, 'Linda', 'Douglas'); -INSERT IGNORE INTO doctors VALUES (4, 'Rafael', 'Ortega'); -INSERT IGNORE INTO doctors VALUES (5, 'Henry', 'Stevens'); -INSERT IGNORE INTO doctors VALUES (6, 'Sharon', 'Jenkins'); - -INSERT IGNORE INTO specialties VALUES (1, 'radiology'); -INSERT IGNORE INTO specialties VALUES (2, 'surgery'); -INSERT IGNORE INTO specialties VALUES (3, 'dentistry'); - -INSERT IGNORE INTO doctor_specialties VALUES (2, 1); -INSERT IGNORE INTO doctor_specialties VALUES (3, 2); -INSERT IGNORE INTO doctor_specialties VALUES (3, 3); -INSERT IGNORE INTO doctor_specialties VALUES (4, 2); -INSERT IGNORE INTO doctor_specialties VALUES (5, 1); - -INSERT IGNORE INTO gender VALUES (1, 'male'); -INSERT IGNORE INTO gender VALUES (2, 'female'); - -INSERT IGNORE INTO parents VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); -INSERT IGNORE INTO parents VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); -INSERT IGNORE INTO parents VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); -INSERT IGNORE INTO parents VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); -INSERT IGNORE INTO parents VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); -INSERT IGNORE INTO parents VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); -INSERT IGNORE INTO parents VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); -INSERT IGNORE INTO parents VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); -INSERT IGNORE INTO parents VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); -INSERT IGNORE INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); - -INSERT IGNORE INTO kids VALUES (1, 'Leo', '2000-09-07', 2, 1); -INSERT IGNORE INTO kids VALUES (2, 'Basil', '2002-08-06', 1, 2); -INSERT IGNORE INTO kids VALUES (3, 'Rosy', '2001-04-17', 2, 3); -INSERT IGNORE INTO kids VALUES (4, 'Jewel', '2000-03-07', 2, 3); -INSERT IGNORE INTO kids VALUES (5, 'Iggy', '2000-11-30', 1, 4); -INSERT IGNORE INTO kids VALUES (6, 'George', '2000-01-20', 2, 5); -INSERT IGNORE INTO kids VALUES (7, 'Samantha', '1995-09-04', 1, 6); -INSERT IGNORE INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6); -INSERT IGNORE INTO kids VALUES (9, 'Lucky', '1999-08-06', 1, 7); -INSERT IGNORE INTO kids VALUES (10, 'Mulligan', '1997-02-24', 2, 8); -INSERT IGNORE INTO kids VALUES (11, 'Freddy', '2000-03-09', 2, 9); -INSERT IGNORE INTO kids VALUES (12, 'Lucky', '2000-06-24', 2, 10); -INSERT IGNORE INTO kids VALUES (13, 'Sly', '2002-06-08', 1, 10); - -INSERT IGNORE INTO visits VALUES (1, 7, '2010-03-04', 'rabies shot'); -INSERT IGNORE INTO visits VALUES (2, 8, '2011-03-04', 'rabies shot'); -INSERT IGNORE INTO visits VALUES (3, 8, '2009-06-04', 'neutered'); -INSERT IGNORE INTO visits VALUES (4, 7, '2008-09-04', 'spayed'); +INSERT IGNORE INTO doctors VALUES (1, 'James', 'Carter'); +INSERT IGNORE INTO doctors VALUES (2, 'Helen', 'Leary'); +INSERT IGNORE INTO doctors VALUES (3, 'Linda', 'Douglas'); +INSERT IGNORE INTO doctors VALUES (4, 'Rafael', 'Ortega'); +INSERT IGNORE INTO doctors VALUES (5, 'Henry', 'Stevens'); +INSERT IGNORE INTO doctors VALUES (6, 'Sharon', 'Jenkins'); + +INSERT IGNORE INTO specialties VALUES (1, 'radiology'); +INSERT IGNORE INTO specialties VALUES (2, 'surgery'); +INSERT IGNORE INTO specialties VALUES (3, 'dentistry'); + +INSERT IGNORE INTO doctor_specialties VALUES (2, 1); +INSERT IGNORE INTO doctor_specialties VALUES (3, 2); +INSERT IGNORE INTO doctor_specialties VALUES (3, 3); +INSERT IGNORE INTO doctor_specialties VALUES (4, 2); +INSERT IGNORE INTO doctor_specialties VALUES (5, 1); + +INSERT IGNORE INTO gender VALUES (1, 'male'); +INSERT IGNORE INTO gender VALUES (2, 'female'); + +INSERT IGNORE INTO parents VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); +INSERT IGNORE INTO parents VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); +INSERT IGNORE INTO parents VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); +INSERT IGNORE INTO parents VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); +INSERT IGNORE INTO parents VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); +INSERT IGNORE INTO parents VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); +INSERT IGNORE INTO parents VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); +INSERT IGNORE INTO parents VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); +INSERT IGNORE INTO parents VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); +INSERT IGNORE INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); + +INSERT IGNORE INTO kids VALUES (1, 'Leo', '2000-09-07', 2, 1); +INSERT IGNORE INTO kids VALUES (2, 'Basil', '2002-08-06', 1, 2); +INSERT IGNORE INTO kids VALUES (3, 'Rosy', '2001-04-17', 2, 3); +INSERT IGNORE INTO kids VALUES (4, 'Jewel', '2000-03-07', 2, 3); +INSERT IGNORE INTO kids VALUES (5, 'Iggy', '2000-11-30', 1, 4); +INSERT IGNORE INTO kids VALUES (6, 'George', '2000-01-20', 2, 5); +INSERT IGNORE INTO kids VALUES (7, 'Samantha', '1995-09-04', 1, 6); +INSERT IGNORE INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6); +INSERT IGNORE INTO kids VALUES (9, 'Lucky', '1999-08-06', 1, 7); +INSERT IGNORE INTO kids VALUES (10, 'Mulligan', '1997-02-24', 2, 8); +INSERT IGNORE INTO kids VALUES (11, 'Freddy', '2000-03-09', 2, 9); +INSERT IGNORE INTO kids VALUES (12, 'Lucky', '2000-06-24', 2, 10); +INSERT IGNORE INTO kids VALUES (13, 'Sly', '2002-06-08', 1, 10); + +INSERT IGNORE INTO visits VALUES (1, 7, '2010-03-04', 'rabies shot'); +INSERT IGNORE INTO visits VALUES (2, 8, '2011-03-04', 'rabies shot'); +INSERT IGNORE INTO visits VALUES (3, 8, '2009-06-04', 'neutered'); +INSERT IGNORE INTO visits VALUES (4, 7, '2008-09-04', 'spayed'); diff --git a/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt b/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt index 6733a9337..83d026c84 100644 --- a/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt +++ b/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt @@ -1,17 +1,17 @@ -================================================================================ -=== Spring PetClinic sample application - MySQL Configuration === -================================================================================ - -@author Sam Brannen -@author Costin Leau -@author Dave Syer - --------------------------------------------------------------------------------- - -1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x), - which can be found here: http://dev.mysql.com/downloads/. Or run the - "docker-compose.yml" from the root of the project (if you have docker installed - locally). - -2) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql" - scripts (or set "spring.datasource.initialize=true" the first time you run the app). +================================================================================ +=== Spring PetClinic sample application - MySQL Configuration === +================================================================================ + +@author Sam Brannen +@author Costin Leau +@author Dave Syer + +-------------------------------------------------------------------------------- + +1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x), + which can be found here: http://dev.mysql.com/downloads/. Or run the + "docker-compose.yml" from the root of the project (if you have docker installed + locally). + +2) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql" + scripts (or set "spring.datasource.initialize=true" the first time you run the app). diff --git a/src/main/resources/db/mysql/schema.sql b/src/main/resources/db/mysql/schema.sql index 16d2bc153..3582c2fab 100644 --- a/src/main/resources/db/mysql/schema.sql +++ b/src/main/resources/db/mysql/schema.sql @@ -1,65 +1,65 @@ -CREATE DATABASE IF NOT EXISTS kidclinic; - -ALTER DATABASE kidclinic - DEFAULT CHARACTER SET utf8 - DEFAULT COLLATE utf8_general_ci; - -GRANT ALL PRIVILEGES ON kidclinic.* TO pc@localhost IDENTIFIED BY 'pc'; - -USE kidclinic; - -CREATE TABLE IF NOT EXISTS doctors ( - id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - first_name VARCHAR(30), - last_name VARCHAR(30), - INDEX(last_name) -) engine=InnoDB; - -CREATE TABLE IF NOT EXISTS specialties ( - id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(80), - INDEX(name) -) engine=InnoDB; - -CREATE TABLE IF NOT EXISTS doctor_specialties ( - doctor_id INT(4) UNSIGNED NOT NULL, - specialty_id INT(4) UNSIGNED NOT NULL, - FOREIGN KEY (doctor_id) REFERENCES doctors(id), - FOREIGN KEY (specialty_id) REFERENCES specialties(id), - UNIQUE (doctor_id,specialty_id) -) engine=InnoDB; - -CREATE TABLE IF NOT EXISTS gender ( - id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(80), - INDEX(name) -) engine=InnoDB; - -CREATE TABLE IF NOT EXISTS parents ( - id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - first_name VARCHAR(30), - last_name VARCHAR(30), - address VARCHAR(255), - city VARCHAR(80), - telephone VARCHAR(20), - INDEX(last_name) -) engine=InnoDB; - -CREATE TABLE IF NOT EXISTS kids ( - id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(30), - birth_date DATE, - gender_id INT(4) UNSIGNED NOT NULL, - parent_id INT(4) UNSIGNED NOT NULL, - INDEX(name), - FOREIGN KEY (parent_id) REFERENCES parents(id), - FOREIGN KEY (gender_id) REFERENCES gender(id) -) engine=InnoDB; - -CREATE TABLE IF NOT EXISTS visits ( - id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - kid_id INT(4) UNSIGNED NOT NULL, - visit_date DATE, - description VARCHAR(255), - FOREIGN KEY (kid_id) REFERENCES kids(id) -) engine=InnoDB; +CREATE DATABASE IF NOT EXISTS kidclinic; + +ALTER DATABASE kidclinic + DEFAULT CHARACTER SET utf8 + DEFAULT COLLATE utf8_general_ci; + +GRANT ALL PRIVILEGES ON kidclinic.* TO pc@localhost IDENTIFIED BY 'pc'; + +USE kidclinic; + +CREATE TABLE IF NOT EXISTS doctors ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(30), + last_name VARCHAR(30), + INDEX(last_name) +) engine=InnoDB; + +CREATE TABLE IF NOT EXISTS specialties ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(80), + INDEX(name) +) engine=InnoDB; + +CREATE TABLE IF NOT EXISTS doctor_specialties ( + doctor_id INT(4) UNSIGNED NOT NULL, + specialty_id INT(4) UNSIGNED NOT NULL, + FOREIGN KEY (doctor_id) REFERENCES doctors(id), + FOREIGN KEY (specialty_id) REFERENCES specialties(id), + UNIQUE (doctor_id,specialty_id) +) engine=InnoDB; + +CREATE TABLE IF NOT EXISTS gender ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(80), + INDEX(name) +) engine=InnoDB; + +CREATE TABLE IF NOT EXISTS parents ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(30), + last_name VARCHAR(30), + address VARCHAR(255), + city VARCHAR(80), + telephone VARCHAR(20), + INDEX(last_name) +) engine=InnoDB; + +CREATE TABLE IF NOT EXISTS kids ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(30), + birth_date DATE, + gender_id INT(4) UNSIGNED NOT NULL, + parent_id INT(4) UNSIGNED NOT NULL, + INDEX(name), + FOREIGN KEY (parent_id) REFERENCES parents(id), + FOREIGN KEY (gender_id) REFERENCES gender(id) +) engine=InnoDB; + +CREATE TABLE IF NOT EXISTS visits ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + kid_id INT(4) UNSIGNED NOT NULL, + visit_date DATE, + description VARCHAR(255), + FOREIGN KEY (kid_id) REFERENCES kids(id) +) engine=InnoDB; diff --git a/src/main/resources/messages/messages.properties b/src/main/resources/messages/messages.properties index 173417a10..24368be9e 100644 --- a/src/main/resources/messages/messages.properties +++ b/src/main/resources/messages/messages.properties @@ -1,8 +1,8 @@ -welcome=Welcome -required=is required -notFound=has not been found -duplicate=is already in use -nonNumeric=must be all numeric -duplicateFormSubmission=Duplicate form submission is not allowed -typeMismatch.date=invalid date -typeMismatch.birthDate=invalid date +welcome=Welcome +required=is required +notFound=has not been found +duplicate=is already in use +nonNumeric=must be all numeric +duplicateFormSubmission=Duplicate form submission is not allowed +typeMismatch.date=invalid date +typeMismatch.birthDate=invalid date diff --git a/src/main/resources/messages/messages_de.properties b/src/main/resources/messages/messages_de.properties index 124bee48b..b679fb83a 100644 --- a/src/main/resources/messages/messages_de.properties +++ b/src/main/resources/messages/messages_de.properties @@ -1,8 +1,8 @@ -welcome=Willkommen -required=muss angegeben werden -notFound=wurde nicht gefunden -duplicate=ist bereits vergeben -nonNumeric=darf nur numerisch sein -duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt -typeMismatch.date=ungültiges Datum -typeMismatch.birthDate=ungültiges Datum +welcome=Willkommen +required=muss angegeben werden +notFound=wurde nicht gefunden +duplicate=ist bereits vergeben +nonNumeric=darf nur numerisch sein +duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt +typeMismatch.date=ungültiges Datum +typeMismatch.birthDate=ungültiges Datum diff --git a/src/main/resources/static/resources/fonts/montserrat-webfont.svg b/src/main/resources/static/resources/fonts/montserrat-webfont.svg index 7bd96bdfd..ba40b157a 100644 --- a/src/main/resources/static/resources/fonts/montserrat-webfont.svg +++ b/src/main/resources/static/resources/fonts/montserrat-webfont.svg @@ -1,1283 +1,1283 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/resources/fonts/varela_round-webfont.svg b/src/main/resources/static/resources/fonts/varela_round-webfont.svg index 3280e2c43..fc892b918 100644 --- a/src/main/resources/static/resources/fonts/varela_round-webfont.svg +++ b/src/main/resources/static/resources/fonts/varela_round-webfont.svg @@ -1,7875 +1,7875 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/doctors/doctorList.html b/src/main/resources/templates/doctors/doctorList.html index 54e8e82ff..54a430b06 100644 --- a/src/main/resources/templates/doctors/doctorList.html +++ b/src/main/resources/templates/doctors/doctorList.html @@ -1,28 +1,28 @@ - - - - - - -

Pediatricians

- -
Name
- - - - - - - - - - - - -
NameSpecialties
none
- - - + + + + + + +

Pediatricians

+ + + + + + + + + + + + + + +
NameSpecialties
none
+ + + diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index 6bb77100e..ee3d6f081 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -1,10 +1,10 @@ - - - - - -

Errors

-

Exception message

- - - + + + + + +

Errors

+

Exception message

+ + + diff --git a/src/main/resources/templates/fragments/inputField.html b/src/main/resources/templates/fragments/inputField.html index 7cef1ee9e..149931bb9 100644 --- a/src/main/resources/templates/fragments/inputField.html +++ b/src/main/resources/templates/fragments/inputField.html @@ -1,26 +1,26 @@ - - -
- -
- -
- - - - - Error - -
-
-
-
- - + + +
+ +
+ +
+ + + + + Error + +
+
+
+
+ + diff --git a/src/main/resources/templates/fragments/layout.html b/src/main/resources/templates/fragments/layout.html index 0e2cce319..a9ab00422 100755 --- a/src/main/resources/templates/fragments/layout.html +++ b/src/main/resources/templates/fragments/layout.html @@ -1,108 +1,108 @@ - - - - - - - - - - KidClinic :: a Spring Framework demonstration - - - - - - - - -
- -
-
- - -
- -
-
- - - - - - - - - - + + + + + + + + + + KidClinic :: a Spring Framework demonstration + + + + + + + + +
+ +
+
+ + +
+ +
+
+ + + + + + + + + + diff --git a/src/main/resources/templates/fragments/selectField.html b/src/main/resources/templates/fragments/selectField.html index 438474463..aed2964c4 100644 --- a/src/main/resources/templates/fragments/selectField.html +++ b/src/main/resources/templates/fragments/selectField.html @@ -1,29 +1,29 @@ - - -
- -
- - -
- - - - - Error - -
-
-
-
- + + +
+ +
+ + +
+ + + + + Error + +
+
+
+
+ \ No newline at end of file diff --git a/src/main/resources/templates/kids/createOrUpdateKidForm.html b/src/main/resources/templates/kids/createOrUpdateKidForm.html index fda0a0594..2eea69fbd 100644 --- a/src/main/resources/templates/kids/createOrUpdateKidForm.html +++ b/src/main/resources/templates/kids/createOrUpdateKidForm.html @@ -1,38 +1,38 @@ - - - - -

- New - Kid -

-
- -
-
- -
- -
-
- - - -
-
-
- -
-
-
- - - - + + + + +

+ New + Kid +

+
+ +
+
+ +
+ +
+
+ + + +
+
+
+ +
+
+
+ + + + diff --git a/src/main/resources/templates/kids/createOrUpdateVisitForm.html b/src/main/resources/templates/kids/createOrUpdateVisitForm.html index 1f48d6574..c76a65bfb 100644 --- a/src/main/resources/templates/kids/createOrUpdateVisitForm.html +++ b/src/main/resources/templates/kids/createOrUpdateVisitForm.html @@ -1,61 +1,61 @@ - - - - -

- New - Visit -

- - Kid - - - - - - - - - - - - - - - -
NameBirth DateTypeParent
- -
-
- - -
- -
-
- - -
-
-
- -
- Previous Visits - - - - - - - - - -
DateDescription
- - + + + + +

+ New + Visit +

+ + Kid + + + + + + + + + + + + + + + +
NameBirth DateTypeParent
+ +
+
+ + +
+ +
+
+ + +
+
+
+ +
+ Previous Visits + + + + + + + + + +
DateDescription
+ + \ No newline at end of file diff --git a/src/main/resources/templates/parents/createOrUpdateParentForm.html b/src/main/resources/templates/parents/createOrUpdateParentForm.html index 71dff284f..56f0dfddb 100644 --- a/src/main/resources/templates/parents/createOrUpdateParentForm.html +++ b/src/main/resources/templates/parents/createOrUpdateParentForm.html @@ -1,30 +1,30 @@ - - - - -

Parent

-
-
- - - - - -
-
-
- -
-
-
- - + + + + +

Parent

+
+
+ + + + + +
+
+
+ +
+
+
+ + diff --git a/src/main/resources/templates/parents/findParents.html b/src/main/resources/templates/parents/findParents.html index d9a362ed4..7b9bfc02a 100644 --- a/src/main/resources/templates/parents/findParents.html +++ b/src/main/resources/templates/parents/findParents.html @@ -1,35 +1,35 @@ - - - - -

Find Parents

- -
-
-
- -
-
-

Error

-
-
-
-
-
-
- -
-
- -
- -
- Add Parent - - - + + + + +

Find Parents

+ +
+
+
+ +
+
+

Error

+
+
+
+
+
+
+ +
+
+ +
+ +
+ Add Parent + + + diff --git a/src/main/resources/templates/parents/parentDetails.html b/src/main/resources/templates/parents/parentDetails.html index 6670667f0..a406b582f 100644 --- a/src/main/resources/templates/parents/parentDetails.html +++ b/src/main/resources/templates/parents/parentDetails.html @@ -1,83 +1,83 @@ - - - - - - - -

Parent Information

- - - - - - - - - - - - - - - - - - - -
Name
Address
City
Telephone
- - Edit - Parent - Add - New Child - -
-
-
-

Children and Visits

- - - - - - - - -
-
-
Name
-
-
Birth Date
-
-
Gender
-
-
-
- - - - - - - - - - - - - - - -
Visit DateDescription
Edit - ChildAdd - Visit
-
- - - - + + + + + + + +

Parent Information

+ + + + + + + + + + + + + + + + + + + +
Name
Address
City
Telephone
+ + Edit + Parent + Add + New Child + +
+
+
+

Children and Visits

+ + + + + + + + +
+
+
Name
+
+
Birth Date
+
+
Gender
+
+
+
+ + + + + + + + + + + + + + + +
Visit DateDescription
Edit + ChildAdd + Visit
+
+ + + + diff --git a/src/main/resources/templates/parents/parentsList.html b/src/main/resources/templates/parents/parentsList.html index c8b6888a3..452f76638 100644 --- a/src/main/resources/templates/parents/parentsList.html +++ b/src/main/resources/templates/parents/parentsList.html @@ -1,33 +1,33 @@ - - - - - - -

Parents

- - - - - - - - - - - - - - - - - -
NameAddressCityTelephoneChildren
- - - - -
- - - + + + + + + +

Parents

+ + + + + + + + + + + + + + + + + +
NameAddressCityTelephoneChildren
+ + + + +
+ + + diff --git a/src/main/resources/templates/reviews.html b/src/main/resources/templates/reviews.html index db6ba00c8..dc3868ec8 100644 --- a/src/main/resources/templates/reviews.html +++ b/src/main/resources/templates/reviews.html @@ -1,10 +1,10 @@ - - - - - -

Reviews

-

We are currently curating our review.

- - - + + + + + +

Reviews

+

We are currently curating our review.

+ + + diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html index c4a15a42c..9a1e36920 100644 --- a/src/main/resources/templates/welcome.html +++ b/src/main/resources/templates/welcome.html @@ -1,142 +1,142 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Our Story

-
- -
-

Creation

-

KidClinic is a platform to simplify healthcare, not for insurance companies but for you: the cutomers and the doctors. We want to streamline how records are managed and simplify the process of managing pediatric health. KidClinic expediates the oft tedious process of permissions for managing a minor's health, organizing the records in an intuitive but archivable mainframe.

- -
- -
-

Features

-
- -
-

Parents

-

The database we utilize allows doctors to safely, securely, search for parents in the system of their practice. Upon search, users are able to see the children, the actual patients, associated with the parent or guardian. This stores all family information in one area, easily compiling family history and a broader view of clinical practice. It is our hope this expediates care for both patients and doctors. - -

-

Doctors

-

KidClinic is a service for parents as well. All registered doctors, verified for quality and certification by us, appear on the doctor listing. Users can search by profession, speciality and history. With tools to filter and search, finding the right doctor for you and your kids has never been easier. - -

- -

Reviews

-

Here at KidClinic, we want to ensure quality care and incorporate facets from disparate sources. This includes an interactive review function, where you can directly review doctors and influence their appearance on the search feature. Your insight makes a difference for future care, directly, immediately.You can also see other's reviews and comments to facilitate your decisions on care. - -

- -
- -
-

The Future

-
- -
-

Our Vision

-

In the ever expanding and fickle internet era it is not enough to have a product. So we have crafted a vision forward, together, to revolutionize healthcare at your finger tips. This means integrating calendars, live notifications of appointment availability, and even mapping your needs. Integration can be scary and rightfully so. But we provide data for you and your family because frankly the current state of healthcare is unacceptable. This is a step in a multitude of miles to perfecting it. - -

-
- To Top -
-
- - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Our Story

+
+ +
+

Creation

+

KidClinic is a platform to simplify healthcare, not for insurance companies but for you: the cutomers and the doctors. We want to streamline how records are managed and simplify the process of managing pediatric health. KidClinic expediates the oft tedious process of permissions for managing a minor's health, organizing the records in an intuitive but archivable mainframe.

+ +
+ +
+

Features

+
+ +
+

Parents

+

The database we utilize allows doctors to safely, securely, search for parents in the system of their practice. Upon search, users are able to see the children, the actual patients, associated with the parent or guardian. This stores all family information in one area, easily compiling family history and a broader view of clinical practice. It is our hope this expediates care for both patients and doctors. + +

+

Doctors

+

KidClinic is a service for parents as well. All registered doctors, verified for quality and certification by us, appear on the doctor listing. Users can search by profession, speciality and history. With tools to filter and search, finding the right doctor for you and your kids has never been easier. + +

+ +

Reviews

+

Here at KidClinic, we want to ensure quality care and incorporate facets from disparate sources. This includes an interactive review function, where you can directly review doctors and influence their appearance on the search feature. Your insight makes a difference for future care, directly, immediately.You can also see other's reviews and comments to facilitate your decisions on care. + +

+ +
+ +
+

The Future

+
+ +
+

Our Vision

+

In the ever expanding and fickle internet era it is not enough to have a product. So we have crafted a vision forward, together, to revolutionize healthcare at your finger tips. This means integrating calendars, live notifications of appointment availability, and even mapping your needs. Integration can be scary and rightfully so. But we provide data for you and your family because frankly the current state of healthcare is unacceptable. This is a step in a multitude of miles to perfecting it. + +

+
+ To Top +
+
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/wro/wro.properties b/src/main/wro/wro.properties index bd6f3a814..9aa2f43ec 100644 --- a/src/main/wro/wro.properties +++ b/src/main/wro/wro.properties @@ -1,4 +1,4 @@ -#List of preProcessors -preProcessors=lessCssImport -#List of postProcessors +#List of preProcessors +preProcessors=lessCssImport +#List of postProcessors postProcessors=less4j \ No newline at end of file diff --git a/src/main/wro/wro.xml b/src/main/wro/wro.xml index 590156d7e..39d3fa873 100644 --- a/src/main/wro/wro.xml +++ b/src/main/wro/wro.xml @@ -1,6 +1,6 @@ - - - classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less - /petclinic.less - - + + + classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less + /petclinic.less + + diff --git a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java index b836d0cc2..933d8dd88 100644 --- a/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java +++ b/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java @@ -1,45 +1,45 @@ -package org.springframework.samples.petclinic.model; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Locale; -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validator; - -import org.junit.Test; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; - -/** - * @author Michael Isvy - * Simple test to make sure that Bean Validation is working - * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) - */ -public class ValidatorTests { - - private Validator createValidator() { - LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); - localValidatorFactoryBean.afterPropertiesSet(); - return localValidatorFactoryBean; - } - - @Test - public void shouldNotValidateWhenFirstNameEmpty() { - - LocaleContextHolder.setLocale(Locale.ENGLISH); - Person person = new Person(); - person.setFirstName(""); - person.setLastName("smith"); - - Validator validator = createValidator(); - Set> constraintViolations = validator.validate(person); - - assertThat(constraintViolations.size()).isEqualTo(1); - ConstraintViolation violation = constraintViolations.iterator().next(); - assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName"); - assertThat(violation.getMessage()).isEqualTo("may not be empty"); - } - -} +package org.springframework.samples.petclinic.model; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Locale; +import java.util.Set; + +import javax.validation.ConstraintViolation; +import javax.validation.Validator; + +import org.junit.Test; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; + +/** + * @author Michael Isvy + * Simple test to make sure that Bean Validation is working + * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) + */ +public class ValidatorTests { + + private Validator createValidator() { + LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); + localValidatorFactoryBean.afterPropertiesSet(); + return localValidatorFactoryBean; + } + + @Test + public void shouldNotValidateWhenFirstNameEmpty() { + + LocaleContextHolder.setLocale(Locale.ENGLISH); + Person person = new Person(); + person.setFirstName(""); + person.setLastName("smith"); + + Validator validator = createValidator(); + Set> constraintViolations = validator.validate(person); + + assertThat(constraintViolations.size()).isEqualTo(1); + ConstraintViolation violation = constraintViolations.iterator().next(); + assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName"); + assertThat(violation.getMessage()).isEqualTo("may not be empty"); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java index 7fccb3b04..0956ffada 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java @@ -1,179 +1,179 @@ -package org.springframework.samples.petclinic.owner; - -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.is; -import static org.mockito.BDDMockito.given; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; - -import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.samples.petclinic.owner.Owner; -import org.springframework.samples.petclinic.owner.OwnerController; -import org.springframework.samples.petclinic.owner.OwnerRepository; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -/** - * Test class for {@link OwnerController} - * - * @author Colin But - */ -@RunWith(SpringRunner.class) -@WebMvcTest(OwnerController.class) -public class OwnerControllerTests { - - private static final int TEST_OWNER_ID = 1; - - @Autowired - private MockMvc mockMvc; - - @MockBean - private OwnerRepository owners; - - private Owner george; - - @Before - public void setup() { - george = new Owner(); - george.setId(TEST_OWNER_ID); - george.setFirstName("George"); - george.setLastName("Franklin"); - george.setAddress("110 W. Liberty St."); - george.setCity("Madison"); - george.setTelephone("6085551023"); - given(this.owners.findById(TEST_OWNER_ID)).willReturn(george); - } - - @Test - public void testInitCreationForm() throws Exception { - mockMvc.perform(get("/owners/new")) - .andExpect(status().isOk()) - .andExpect(model().attributeExists("owner")) - .andExpect(view().name("owners/createOrUpdateOwnerForm")); - } - - @Test - public void testProcessCreationFormSuccess() throws Exception { - mockMvc.perform(post("/owners/new") - .param("firstName", "Joe") - .param("lastName", "Bloggs") - .param("address", "123 Caramel Street") - .param("city", "London") - .param("telephone", "01316761638") - ) - .andExpect(status().is3xxRedirection()); - } - - @Test - public void testProcessCreationFormHasErrors() throws Exception { - mockMvc.perform(post("/owners/new") - .param("firstName", "Joe") - .param("lastName", "Bloggs") - .param("city", "London") - ) - .andExpect(status().isOk()) - .andExpect(model().attributeHasErrors("owner")) - .andExpect(model().attributeHasFieldErrors("owner", "address")) - .andExpect(model().attributeHasFieldErrors("owner", "telephone")) - .andExpect(view().name("owners/createOrUpdateOwnerForm")); - } - - @Test - public void testInitFindForm() throws Exception { - mockMvc.perform(get("/owners/find")) - .andExpect(status().isOk()) - .andExpect(model().attributeExists("owner")) - .andExpect(view().name("owners/findOwners")); - } - - @Test - public void testProcessFindFormSuccess() throws Exception { - given(this.owners.findByLastName("")).willReturn(Lists.newArrayList(george, new Owner())); - mockMvc.perform(get("/owners")) - .andExpect(status().isOk()) - .andExpect(view().name("owners/ownersList")); - } - - @Test - public void testProcessFindFormByLastName() throws Exception { - given(this.owners.findByLastName(george.getLastName())).willReturn(Lists.newArrayList(george)); - mockMvc.perform(get("/owners") - .param("lastName", "Franklin") - ) - .andExpect(status().is3xxRedirection()) - .andExpect(view().name("redirect:/owners/" + TEST_OWNER_ID)); - } - - @Test - public void testProcessFindFormNoOwnersFound() throws Exception { - mockMvc.perform(get("/owners") - .param("lastName", "Unknown Surname") - ) - .andExpect(status().isOk()) - .andExpect(model().attributeHasFieldErrors("owner", "lastName")) - .andExpect(model().attributeHasFieldErrorCode("owner", "lastName", "notFound")) - .andExpect(view().name("owners/findOwners")); - } - - @Test - public void testInitUpdateOwnerForm() throws Exception { - mockMvc.perform(get("/owners/{ownerId}/edit", TEST_OWNER_ID)) - .andExpect(status().isOk()) - .andExpect(model().attributeExists("owner")) - .andExpect(model().attribute("owner", hasProperty("lastName", is("Franklin")))) - .andExpect(model().attribute("owner", hasProperty("firstName", is("George")))) - .andExpect(model().attribute("owner", hasProperty("address", is("110 W. Liberty St.")))) - .andExpect(model().attribute("owner", hasProperty("city", is("Madison")))) - .andExpect(model().attribute("owner", hasProperty("telephone", is("6085551023")))) - .andExpect(view().name("owners/createOrUpdateOwnerForm")); - } - - @Test - public void testProcessUpdateOwnerFormSuccess() throws Exception { - mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID) - .param("firstName", "Joe") - .param("lastName", "Bloggs") - .param("address", "123 Caramel Street") - .param("city", "London") - .param("telephone", "01616291589") - ) - .andExpect(status().is3xxRedirection()) - .andExpect(view().name("redirect:/owners/{ownerId}")); - } - - @Test - public void testProcessUpdateOwnerFormHasErrors() throws Exception { - mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID) - .param("firstName", "Joe") - .param("lastName", "Bloggs") - .param("city", "London") - ) - .andExpect(status().isOk()) - .andExpect(model().attributeHasErrors("owner")) - .andExpect(model().attributeHasFieldErrors("owner", "address")) - .andExpect(model().attributeHasFieldErrors("owner", "telephone")) - .andExpect(view().name("owners/createOrUpdateOwnerForm")); - } - - @Test - public void testShowOwner() throws Exception { - mockMvc.perform(get("/owners/{ownerId}", TEST_OWNER_ID)) - .andExpect(status().isOk()) - .andExpect(model().attribute("owner", hasProperty("lastName", is("Franklin")))) - .andExpect(model().attribute("owner", hasProperty("firstName", is("George")))) - .andExpect(model().attribute("owner", hasProperty("address", is("110 W. Liberty St.")))) - .andExpect(model().attribute("owner", hasProperty("city", is("Madison")))) - .andExpect(model().attribute("owner", hasProperty("telephone", is("6085551023")))) - .andExpect(view().name("owners/ownerDetails")); - } - -} +package org.springframework.samples.petclinic.owner; + +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.is; +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import org.assertj.core.util.Lists; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.samples.petclinic.owner.Owner; +import org.springframework.samples.petclinic.owner.OwnerController; +import org.springframework.samples.petclinic.owner.OwnerRepository; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +/** + * Test class for {@link OwnerController} + * + * @author Colin But + */ +@RunWith(SpringRunner.class) +@WebMvcTest(OwnerController.class) +public class OwnerControllerTests { + + private static final int TEST_OWNER_ID = 1; + + @Autowired + private MockMvc mockMvc; + + @MockBean + private OwnerRepository owners; + + private Owner george; + + @Before + public void setup() { + george = new Owner(); + george.setId(TEST_OWNER_ID); + george.setFirstName("George"); + george.setLastName("Franklin"); + george.setAddress("110 W. Liberty St."); + george.setCity("Madison"); + george.setTelephone("6085551023"); + given(this.owners.findById(TEST_OWNER_ID)).willReturn(george); + } + + @Test + public void testInitCreationForm() throws Exception { + mockMvc.perform(get("/owners/new")) + .andExpect(status().isOk()) + .andExpect(model().attributeExists("owner")) + .andExpect(view().name("owners/createOrUpdateOwnerForm")); + } + + @Test + public void testProcessCreationFormSuccess() throws Exception { + mockMvc.perform(post("/owners/new") + .param("firstName", "Joe") + .param("lastName", "Bloggs") + .param("address", "123 Caramel Street") + .param("city", "London") + .param("telephone", "01316761638") + ) + .andExpect(status().is3xxRedirection()); + } + + @Test + public void testProcessCreationFormHasErrors() throws Exception { + mockMvc.perform(post("/owners/new") + .param("firstName", "Joe") + .param("lastName", "Bloggs") + .param("city", "London") + ) + .andExpect(status().isOk()) + .andExpect(model().attributeHasErrors("owner")) + .andExpect(model().attributeHasFieldErrors("owner", "address")) + .andExpect(model().attributeHasFieldErrors("owner", "telephone")) + .andExpect(view().name("owners/createOrUpdateOwnerForm")); + } + + @Test + public void testInitFindForm() throws Exception { + mockMvc.perform(get("/owners/find")) + .andExpect(status().isOk()) + .andExpect(model().attributeExists("owner")) + .andExpect(view().name("owners/findOwners")); + } + + @Test + public void testProcessFindFormSuccess() throws Exception { + given(this.owners.findByLastName("")).willReturn(Lists.newArrayList(george, new Owner())); + mockMvc.perform(get("/owners")) + .andExpect(status().isOk()) + .andExpect(view().name("owners/ownersList")); + } + + @Test + public void testProcessFindFormByLastName() throws Exception { + given(this.owners.findByLastName(george.getLastName())).willReturn(Lists.newArrayList(george)); + mockMvc.perform(get("/owners") + .param("lastName", "Franklin") + ) + .andExpect(status().is3xxRedirection()) + .andExpect(view().name("redirect:/owners/" + TEST_OWNER_ID)); + } + + @Test + public void testProcessFindFormNoOwnersFound() throws Exception { + mockMvc.perform(get("/owners") + .param("lastName", "Unknown Surname") + ) + .andExpect(status().isOk()) + .andExpect(model().attributeHasFieldErrors("owner", "lastName")) + .andExpect(model().attributeHasFieldErrorCode("owner", "lastName", "notFound")) + .andExpect(view().name("owners/findOwners")); + } + + @Test + public void testInitUpdateOwnerForm() throws Exception { + mockMvc.perform(get("/owners/{ownerId}/edit", TEST_OWNER_ID)) + .andExpect(status().isOk()) + .andExpect(model().attributeExists("owner")) + .andExpect(model().attribute("owner", hasProperty("lastName", is("Franklin")))) + .andExpect(model().attribute("owner", hasProperty("firstName", is("George")))) + .andExpect(model().attribute("owner", hasProperty("address", is("110 W. Liberty St.")))) + .andExpect(model().attribute("owner", hasProperty("city", is("Madison")))) + .andExpect(model().attribute("owner", hasProperty("telephone", is("6085551023")))) + .andExpect(view().name("owners/createOrUpdateOwnerForm")); + } + + @Test + public void testProcessUpdateOwnerFormSuccess() throws Exception { + mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID) + .param("firstName", "Joe") + .param("lastName", "Bloggs") + .param("address", "123 Caramel Street") + .param("city", "London") + .param("telephone", "01616291589") + ) + .andExpect(status().is3xxRedirection()) + .andExpect(view().name("redirect:/owners/{ownerId}")); + } + + @Test + public void testProcessUpdateOwnerFormHasErrors() throws Exception { + mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID) + .param("firstName", "Joe") + .param("lastName", "Bloggs") + .param("city", "London") + ) + .andExpect(status().isOk()) + .andExpect(model().attributeHasErrors("owner")) + .andExpect(model().attributeHasFieldErrors("owner", "address")) + .andExpect(model().attributeHasFieldErrors("owner", "telephone")) + .andExpect(view().name("owners/createOrUpdateOwnerForm")); + } + + @Test + public void testShowOwner() throws Exception { + mockMvc.perform(get("/owners/{ownerId}", TEST_OWNER_ID)) + .andExpect(status().isOk()) + .andExpect(model().attribute("owner", hasProperty("lastName", is("Franklin")))) + .andExpect(model().attribute("owner", hasProperty("firstName", is("George")))) + .andExpect(model().attribute("owner", hasProperty("address", is("110 W. Liberty St.")))) + .andExpect(model().attribute("owner", hasProperty("city", is("Madison")))) + .andExpect(model().attribute("owner", hasProperty("telephone", is("6085551023")))) + .andExpect(view().name("owners/ownerDetails")); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java index f56931cb6..f07847c61 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java @@ -1,127 +1,127 @@ -package org.springframework.samples.petclinic.owner; - -import static org.mockito.BDDMockito.given; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; - -import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; -import org.springframework.samples.petclinic.owner.Owner; -import org.springframework.samples.petclinic.owner.OwnerRepository; -import org.springframework.samples.petclinic.owner.Pet; -import org.springframework.samples.petclinic.owner.PetController; -import org.springframework.samples.petclinic.owner.PetRepository; -import org.springframework.samples.petclinic.owner.PetType; -import org.springframework.samples.petclinic.owner.PetTypeFormatter; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -/** - * Test class for the {@link PetController} - * - * @author Colin But - */ -@RunWith(SpringRunner.class) -@WebMvcTest(value = PetController.class, - includeFilters = @ComponentScan.Filter( - value = PetTypeFormatter.class, - type = FilterType.ASSIGNABLE_TYPE)) -public class PetControllerTests { - - private static final int TEST_OWNER_ID = 1; - private static final int TEST_PET_ID = 1; - - - @Autowired - private MockMvc mockMvc; - - @MockBean - private PetRepository pets; - - @MockBean - private OwnerRepository owners; - - @Before - public void setup() { - PetType cat = new PetType(); - cat.setId(3); - cat.setName("hamster"); - given(this.pets.findPetTypes()).willReturn(Lists.newArrayList(cat)); - given(this.owners.findById(TEST_OWNER_ID)).willReturn(new Owner()); - given(this.pets.findById(TEST_PET_ID)).willReturn(new Pet()); - - } - - @Test - public void testInitCreationForm() throws Exception { - mockMvc.perform(get("/owners/{ownerId}/pets/new", TEST_OWNER_ID)) - .andExpect(status().isOk()) - .andExpect(view().name("pets/createOrUpdatePetForm")) - .andExpect(model().attributeExists("pet")); - } - - @Test - public void testProcessCreationFormSuccess() throws Exception { - mockMvc.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID) - .param("name", "Betty") - .param("type", "hamster") - .param("birthDate", "2015/02/12") - ) - .andExpect(status().is3xxRedirection()) - .andExpect(view().name("redirect:/owners/{ownerId}")); - } - - @Test - public void testProcessCreationFormHasErrors() throws Exception { - mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID) - .param("name", "Betty") - .param("birthDate", "2015/02/12") - ) - .andExpect(model().attributeHasNoErrors("owner")) - .andExpect(model().attributeHasErrors("pet")) - .andExpect(status().isOk()) - .andExpect(view().name("pets/createOrUpdatePetForm")); - } - - @Test - public void testInitUpdateForm() throws Exception { - mockMvc.perform(get("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID)) - .andExpect(status().isOk()) - .andExpect(model().attributeExists("pet")) - .andExpect(view().name("pets/createOrUpdatePetForm")); - } - - @Test - public void testProcessUpdateFormSuccess() throws Exception { - mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID) - .param("name", "Betty") - .param("type", "hamster") - .param("birthDate", "2015/02/12") - ) - .andExpect(status().is3xxRedirection()) - .andExpect(view().name("redirect:/owners/{ownerId}")); - } - - @Test - public void testProcessUpdateFormHasErrors() throws Exception { - mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID) - .param("name", "Betty") - .param("birthDate", "2015/02/12") - ) - .andExpect(model().attributeHasNoErrors("owner")) - .andExpect(model().attributeHasErrors("pet")) - .andExpect(status().isOk()) - .andExpect(view().name("pets/createOrUpdatePetForm")); - } - -} +package org.springframework.samples.petclinic.owner; + +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import org.assertj.core.util.Lists; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.samples.petclinic.owner.Owner; +import org.springframework.samples.petclinic.owner.OwnerRepository; +import org.springframework.samples.petclinic.owner.Pet; +import org.springframework.samples.petclinic.owner.PetController; +import org.springframework.samples.petclinic.owner.PetRepository; +import org.springframework.samples.petclinic.owner.PetType; +import org.springframework.samples.petclinic.owner.PetTypeFormatter; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +/** + * Test class for the {@link PetController} + * + * @author Colin But + */ +@RunWith(SpringRunner.class) +@WebMvcTest(value = PetController.class, + includeFilters = @ComponentScan.Filter( + value = PetTypeFormatter.class, + type = FilterType.ASSIGNABLE_TYPE)) +public class PetControllerTests { + + private static final int TEST_OWNER_ID = 1; + private static final int TEST_PET_ID = 1; + + + @Autowired + private MockMvc mockMvc; + + @MockBean + private PetRepository pets; + + @MockBean + private OwnerRepository owners; + + @Before + public void setup() { + PetType cat = new PetType(); + cat.setId(3); + cat.setName("hamster"); + given(this.pets.findPetTypes()).willReturn(Lists.newArrayList(cat)); + given(this.owners.findById(TEST_OWNER_ID)).willReturn(new Owner()); + given(this.pets.findById(TEST_PET_ID)).willReturn(new Pet()); + + } + + @Test + public void testInitCreationForm() throws Exception { + mockMvc.perform(get("/owners/{ownerId}/pets/new", TEST_OWNER_ID)) + .andExpect(status().isOk()) + .andExpect(view().name("pets/createOrUpdatePetForm")) + .andExpect(model().attributeExists("pet")); + } + + @Test + public void testProcessCreationFormSuccess() throws Exception { + mockMvc.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID) + .param("name", "Betty") + .param("type", "hamster") + .param("birthDate", "2015/02/12") + ) + .andExpect(status().is3xxRedirection()) + .andExpect(view().name("redirect:/owners/{ownerId}")); + } + + @Test + public void testProcessCreationFormHasErrors() throws Exception { + mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID) + .param("name", "Betty") + .param("birthDate", "2015/02/12") + ) + .andExpect(model().attributeHasNoErrors("owner")) + .andExpect(model().attributeHasErrors("pet")) + .andExpect(status().isOk()) + .andExpect(view().name("pets/createOrUpdatePetForm")); + } + + @Test + public void testInitUpdateForm() throws Exception { + mockMvc.perform(get("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID)) + .andExpect(status().isOk()) + .andExpect(model().attributeExists("pet")) + .andExpect(view().name("pets/createOrUpdatePetForm")); + } + + @Test + public void testProcessUpdateFormSuccess() throws Exception { + mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID) + .param("name", "Betty") + .param("type", "hamster") + .param("birthDate", "2015/02/12") + ) + .andExpect(status().is3xxRedirection()) + .andExpect(view().name("redirect:/owners/{ownerId}")); + } + + @Test + public void testProcessUpdateFormHasErrors() throws Exception { + mockMvc.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID) + .param("name", "Betty") + .param("birthDate", "2015/02/12") + ) + .andExpect(model().attributeHasNoErrors("owner")) + .andExpect(model().attributeHasErrors("pet")) + .andExpect(status().isOk()) + .andExpect(view().name("pets/createOrUpdatePetForm")); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java b/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java index f332257bc..cbd97b61f 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java @@ -1,80 +1,80 @@ -package org.springframework.samples.petclinic.owner; - -import static org.junit.Assert.assertEquals; - -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Locale; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.springframework.samples.petclinic.owner.PetRepository; -import org.springframework.samples.petclinic.owner.PetType; -import org.springframework.samples.petclinic.owner.PetTypeFormatter; - -/** - * Test class for {@link PetTypeFormatter} - * - * @author Colin But - */ -@RunWith(MockitoJUnitRunner.class) -public class PetTypeFormatterTests { - - @Mock - private PetRepository pets; - - private PetTypeFormatter petTypeFormatter; - - @Before - public void setup() { - this.petTypeFormatter = new PetTypeFormatter(pets); - } - - @Test - public void testPrint() { - PetType petType = new PetType(); - petType.setName("Hamster"); - String petTypeName = this.petTypeFormatter.print(petType, Locale.ENGLISH); - assertEquals("Hamster", petTypeName); - } - - @Test - public void shouldParse() throws ParseException { - Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes()); - PetType petType = petTypeFormatter.parse("Bird", Locale.ENGLISH); - assertEquals("Bird", petType.getName()); - } - - @Test(expected = ParseException.class) - public void shouldThrowParseException() throws ParseException { - Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes()); - petTypeFormatter.parse("Fish", Locale.ENGLISH); - } - - /** - * Helper method to produce some sample pet types just for test purpose - * - * @return {@link Collection} of {@link PetType} - */ - private List makePetTypes() { - List petTypes = new ArrayList<>(); - petTypes.add(new PetType(){ - { - setName("Dog"); - } - }); - petTypes.add(new PetType(){ - { - setName("Bird"); - } - }); - return petTypes; - } - -} +package org.springframework.samples.petclinic.owner; + +import static org.junit.Assert.assertEquals; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.samples.petclinic.owner.PetRepository; +import org.springframework.samples.petclinic.owner.PetType; +import org.springframework.samples.petclinic.owner.PetTypeFormatter; + +/** + * Test class for {@link PetTypeFormatter} + * + * @author Colin But + */ +@RunWith(MockitoJUnitRunner.class) +public class PetTypeFormatterTests { + + @Mock + private PetRepository pets; + + private PetTypeFormatter petTypeFormatter; + + @Before + public void setup() { + this.petTypeFormatter = new PetTypeFormatter(pets); + } + + @Test + public void testPrint() { + PetType petType = new PetType(); + petType.setName("Hamster"); + String petTypeName = this.petTypeFormatter.print(petType, Locale.ENGLISH); + assertEquals("Hamster", petTypeName); + } + + @Test + public void shouldParse() throws ParseException { + Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes()); + PetType petType = petTypeFormatter.parse("Bird", Locale.ENGLISH); + assertEquals("Bird", petType.getName()); + } + + @Test(expected = ParseException.class) + public void shouldThrowParseException() throws ParseException { + Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes()); + petTypeFormatter.parse("Fish", Locale.ENGLISH); + } + + /** + * Helper method to produce some sample pet types just for test purpose + * + * @return {@link Collection} of {@link PetType} + */ + private List makePetTypes() { + List petTypes = new ArrayList<>(); + petTypes.add(new PetType(){ + { + setName("Dog"); + } + }); + petTypes.add(new PetType(){ + { + setName("Bird"); + } + }); + return petTypes; + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java index 08d61360e..32a72daac 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/VisitControllerTests.java @@ -1,75 +1,75 @@ -package org.springframework.samples.petclinic.owner; - -import static org.mockito.BDDMockito.given; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.samples.petclinic.owner.Pet; -import org.springframework.samples.petclinic.owner.PetRepository; -import org.springframework.samples.petclinic.owner.VisitController; -import org.springframework.samples.petclinic.visit.VisitRepository; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -/** - * Test class for {@link VisitController} - * - * @author Colin But - */ -@RunWith(SpringRunner.class) -@WebMvcTest(VisitController.class) -public class VisitControllerTests { - - private static final int TEST_PET_ID = 1; - - @Autowired - private MockMvc mockMvc; - - @MockBean - private VisitRepository visits; - - @MockBean - private PetRepository pets; - - @Before - public void init() { - given(this.pets.findById(TEST_PET_ID)).willReturn(new Pet()); - } - - @Test - public void testInitNewVisitForm() throws Exception { - mockMvc.perform(get("/owners/*/pets/{petId}/visits/new", TEST_PET_ID)) - .andExpect(status().isOk()) - .andExpect(view().name("pets/createOrUpdateVisitForm")); - } - - @Test - public void testProcessNewVisitFormSuccess() throws Exception { - mockMvc.perform(post("/owners/*/pets/{petId}/visits/new", TEST_PET_ID) - .param("name", "George") - .param("description", "Visit Description") - ) - .andExpect(status().is3xxRedirection()) - .andExpect(view().name("redirect:/owners/{ownerId}")); - } - - @Test - public void testProcessNewVisitFormHasErrors() throws Exception { - mockMvc.perform(post("/owners/*/pets/{petId}/visits/new", TEST_PET_ID) - .param("name", "George") - ) - .andExpect(model().attributeHasErrors("visit")) - .andExpect(status().isOk()) - .andExpect(view().name("pets/createOrUpdateVisitForm")); - } - -} +package org.springframework.samples.petclinic.owner; + +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.samples.petclinic.owner.Pet; +import org.springframework.samples.petclinic.owner.PetRepository; +import org.springframework.samples.petclinic.owner.VisitController; +import org.springframework.samples.petclinic.visit.VisitRepository; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +/** + * Test class for {@link VisitController} + * + * @author Colin But + */ +@RunWith(SpringRunner.class) +@WebMvcTest(VisitController.class) +public class VisitControllerTests { + + private static final int TEST_PET_ID = 1; + + @Autowired + private MockMvc mockMvc; + + @MockBean + private VisitRepository visits; + + @MockBean + private PetRepository pets; + + @Before + public void init() { + given(this.pets.findById(TEST_PET_ID)).willReturn(new Pet()); + } + + @Test + public void testInitNewVisitForm() throws Exception { + mockMvc.perform(get("/owners/*/pets/{petId}/visits/new", TEST_PET_ID)) + .andExpect(status().isOk()) + .andExpect(view().name("pets/createOrUpdateVisitForm")); + } + + @Test + public void testProcessNewVisitFormSuccess() throws Exception { + mockMvc.perform(post("/owners/*/pets/{petId}/visits/new", TEST_PET_ID) + .param("name", "George") + .param("description", "Visit Description") + ) + .andExpect(status().is3xxRedirection()) + .andExpect(view().name("redirect:/owners/{ownerId}")); + } + + @Test + public void testProcessNewVisitFormHasErrors() throws Exception { + mockMvc.perform(post("/owners/*/pets/{petId}/visits/new", TEST_PET_ID) + .param("name", "George") + ) + .andExpect(model().attributeHasErrors("visit")) + .andExpect(status().isOk()) + .andExpect(view().name("pets/createOrUpdateVisitForm")); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java index 7ed5bf8a5..a3fca3fc6 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java @@ -1,206 +1,206 @@ -package org.springframework.samples.petclinic.service; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collection; -import java.util.Date; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.samples.petclinic.owner.Owner; -import org.springframework.samples.petclinic.owner.OwnerRepository; -import org.springframework.samples.petclinic.owner.Pet; -import org.springframework.samples.petclinic.owner.PetRepository; -import org.springframework.samples.petclinic.owner.PetType; -import org.springframework.samples.petclinic.vet.Vet; -import org.springframework.samples.petclinic.vet.VetRepository; -import org.springframework.samples.petclinic.visit.Visit; -import org.springframework.samples.petclinic.visit.VisitRepository; -import org.springframework.stereotype.Service; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -/** - * Integration test of the Service and the Repository layer. - *

- * ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided by the Spring - * TestContext Framework:

  • Spring IoC container caching which spares us unnecessary set up - * time between test execution.
  • Dependency Injection of test fixture instances, meaning that - * we don't need to perform application context lookups. See the use of {@link Autowired @Autowired} on the {@link - * ClinicServiceTests#clinicService clinicService} instance variable, which uses autowiring by - * type.
  • Transaction management, meaning each test method is executed in its own transaction, - * which is automatically rolled back by default. Thus, even if tests insert or otherwise change database state, there - * is no need for a teardown or cleanup script.
  • An {@link org.springframework.context.ApplicationContext - * ApplicationContext} is also inherited and can be used for explicit bean lookup if necessary.
- * - * @author Ken Krebs - * @author Rod Johnson - * @author Juergen Hoeller - * @author Sam Brannen - * @author Michael Isvy - * @author Dave Syer - */ - -@RunWith(SpringRunner.class) -@DataJpaTest(includeFilters = @ComponentScan.Filter(Service.class)) -public class ClinicServiceTests { - - @Autowired - protected OwnerRepository owners; - - @Autowired - protected PetRepository pets; - - @Autowired - protected VisitRepository visits; - - @Autowired - protected VetRepository vets; - - @Test - public void shouldFindOwnersByLastName() { - Collection owners = this.owners.findByLastName("Davis"); - assertThat(owners.size()).isEqualTo(2); - - owners = this.owners.findByLastName("Daviss"); - assertThat(owners.isEmpty()).isTrue(); - } - - @Test - public void shouldFindSingleOwnerWithPet() { - Owner owner = this.owners.findById(1); - assertThat(owner.getLastName()).startsWith("Franklin"); - assertThat(owner.getPets().size()).isEqualTo(1); - assertThat(owner.getPets().get(0).getType()).isNotNull(); - assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat"); - } - - @Test - @Transactional - public void shouldInsertOwner() { - Collection owners = this.owners.findByLastName("Schultz"); - int found = owners.size(); - - Owner owner = new Owner(); - owner.setFirstName("Sam"); - owner.setLastName("Schultz"); - owner.setAddress("4, Evans Street"); - owner.setCity("Wollongong"); - owner.setTelephone("4444444444"); - this.owners.save(owner); - assertThat(owner.getId().longValue()).isNotEqualTo(0); - - owners = this.owners.findByLastName("Schultz"); - assertThat(owners.size()).isEqualTo(found + 1); - } - - @Test - @Transactional - public void shouldUpdateOwner() { - Owner owner = this.owners.findById(1); - String oldLastName = owner.getLastName(); - String newLastName = oldLastName + "X"; - - owner.setLastName(newLastName); - this.owners.save(owner); - - // retrieving new name from database - owner = this.owners.findById(1); - assertThat(owner.getLastName()).isEqualTo(newLastName); - } - - @Test - public void shouldFindPetWithCorrectId() { - Pet pet7 = this.pets.findById(7); - assertThat(pet7.getName()).startsWith("Samantha"); - assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean"); - - } - - @Test - public void shouldFindAllPetTypes() { - Collection petTypes = this.pets.findPetTypes(); - - PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1); - assertThat(petType1.getName()).isEqualTo("cat"); - PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4); - assertThat(petType4.getName()).isEqualTo("snake"); - } - - @Test - @Transactional - public void shouldInsertPetIntoDatabaseAndGenerateId() { - Owner owner6 = this.owners.findById(6); - int found = owner6.getPets().size(); - - Pet pet = new Pet(); - pet.setName("bowser"); - Collection types = this.pets.findPetTypes(); - pet.setType(EntityUtils.getById(types, PetType.class, 2)); - pet.setBirthDate(new Date()); - owner6.addPet(pet); - assertThat(owner6.getPets().size()).isEqualTo(found + 1); - - this.pets.save(pet); - this.owners.save(owner6); - - owner6 = this.owners.findById(6); - assertThat(owner6.getPets().size()).isEqualTo(found + 1); - // checks that id has been generated - assertThat(pet.getId()).isNotNull(); - } - - @Test - @Transactional - public void shouldUpdatePetName() throws Exception { - Pet pet7 = this.pets.findById(7); - String oldName = pet7.getName(); - - String newName = oldName + "X"; - pet7.setName(newName); - this.pets.save(pet7); - - pet7 = this.pets.findById(7); - assertThat(pet7.getName()).isEqualTo(newName); - } - - @Test - public void shouldFindVets() { - Collection vets = this.vets.findAll(); - - Vet vet = EntityUtils.getById(vets, Vet.class, 3); - assertThat(vet.getLastName()).isEqualTo("Douglas"); - assertThat(vet.getNrOfSpecialties()).isEqualTo(2); - assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry"); - assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery"); - } - - @Test - @Transactional - public void shouldAddNewVisitForPet() { - Pet pet7 = this.pets.findById(7); - int found = pet7.getVisits().size(); - Visit visit = new Visit(); - pet7.addVisit(visit); - visit.setDescription("test"); - this.visits.save(visit); - this.pets.save(pet7); - - pet7 = this.pets.findById(7); - assertThat(pet7.getVisits().size()).isEqualTo(found + 1); - assertThat(visit.getId()).isNotNull(); - } - - @Test - public void shouldFindVisitsByPetId() throws Exception { - Collection visits = this.visits.findByPetId(7); - assertThat(visits.size()).isEqualTo(2); - Visit[] visitArr = visits.toArray(new Visit[visits.size()]); - assertThat(visitArr[0].getDate()).isNotNull(); - assertThat(visitArr[0].getPetId()).isEqualTo(7); - } - -} +package org.springframework.samples.petclinic.service; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Collection; +import java.util.Date; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.samples.petclinic.owner.Owner; +import org.springframework.samples.petclinic.owner.OwnerRepository; +import org.springframework.samples.petclinic.owner.Pet; +import org.springframework.samples.petclinic.owner.PetRepository; +import org.springframework.samples.petclinic.owner.PetType; +import org.springframework.samples.petclinic.vet.Vet; +import org.springframework.samples.petclinic.vet.VetRepository; +import org.springframework.samples.petclinic.visit.Visit; +import org.springframework.samples.petclinic.visit.VisitRepository; +import org.springframework.stereotype.Service; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +/** + * Integration test of the Service and the Repository layer. + *

+ * ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided by the Spring + * TestContext Framework:

  • Spring IoC container caching which spares us unnecessary set up + * time between test execution.
  • Dependency Injection of test fixture instances, meaning that + * we don't need to perform application context lookups. See the use of {@link Autowired @Autowired} on the {@link + * ClinicServiceTests#clinicService clinicService} instance variable, which uses autowiring by + * type.
  • Transaction management, meaning each test method is executed in its own transaction, + * which is automatically rolled back by default. Thus, even if tests insert or otherwise change database state, there + * is no need for a teardown or cleanup script.
  • An {@link org.springframework.context.ApplicationContext + * ApplicationContext} is also inherited and can be used for explicit bean lookup if necessary.
+ * + * @author Ken Krebs + * @author Rod Johnson + * @author Juergen Hoeller + * @author Sam Brannen + * @author Michael Isvy + * @author Dave Syer + */ + +@RunWith(SpringRunner.class) +@DataJpaTest(includeFilters = @ComponentScan.Filter(Service.class)) +public class ClinicServiceTests { + + @Autowired + protected OwnerRepository owners; + + @Autowired + protected PetRepository pets; + + @Autowired + protected VisitRepository visits; + + @Autowired + protected VetRepository vets; + + @Test + public void shouldFindOwnersByLastName() { + Collection owners = this.owners.findByLastName("Davis"); + assertThat(owners.size()).isEqualTo(2); + + owners = this.owners.findByLastName("Daviss"); + assertThat(owners.isEmpty()).isTrue(); + } + + @Test + public void shouldFindSingleOwnerWithPet() { + Owner owner = this.owners.findById(1); + assertThat(owner.getLastName()).startsWith("Franklin"); + assertThat(owner.getPets().size()).isEqualTo(1); + assertThat(owner.getPets().get(0).getType()).isNotNull(); + assertThat(owner.getPets().get(0).getType().getName()).isEqualTo("cat"); + } + + @Test + @Transactional + public void shouldInsertOwner() { + Collection owners = this.owners.findByLastName("Schultz"); + int found = owners.size(); + + Owner owner = new Owner(); + owner.setFirstName("Sam"); + owner.setLastName("Schultz"); + owner.setAddress("4, Evans Street"); + owner.setCity("Wollongong"); + owner.setTelephone("4444444444"); + this.owners.save(owner); + assertThat(owner.getId().longValue()).isNotEqualTo(0); + + owners = this.owners.findByLastName("Schultz"); + assertThat(owners.size()).isEqualTo(found + 1); + } + + @Test + @Transactional + public void shouldUpdateOwner() { + Owner owner = this.owners.findById(1); + String oldLastName = owner.getLastName(); + String newLastName = oldLastName + "X"; + + owner.setLastName(newLastName); + this.owners.save(owner); + + // retrieving new name from database + owner = this.owners.findById(1); + assertThat(owner.getLastName()).isEqualTo(newLastName); + } + + @Test + public void shouldFindPetWithCorrectId() { + Pet pet7 = this.pets.findById(7); + assertThat(pet7.getName()).startsWith("Samantha"); + assertThat(pet7.getOwner().getFirstName()).isEqualTo("Jean"); + + } + + @Test + public void shouldFindAllPetTypes() { + Collection petTypes = this.pets.findPetTypes(); + + PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1); + assertThat(petType1.getName()).isEqualTo("cat"); + PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4); + assertThat(petType4.getName()).isEqualTo("snake"); + } + + @Test + @Transactional + public void shouldInsertPetIntoDatabaseAndGenerateId() { + Owner owner6 = this.owners.findById(6); + int found = owner6.getPets().size(); + + Pet pet = new Pet(); + pet.setName("bowser"); + Collection types = this.pets.findPetTypes(); + pet.setType(EntityUtils.getById(types, PetType.class, 2)); + pet.setBirthDate(new Date()); + owner6.addPet(pet); + assertThat(owner6.getPets().size()).isEqualTo(found + 1); + + this.pets.save(pet); + this.owners.save(owner6); + + owner6 = this.owners.findById(6); + assertThat(owner6.getPets().size()).isEqualTo(found + 1); + // checks that id has been generated + assertThat(pet.getId()).isNotNull(); + } + + @Test + @Transactional + public void shouldUpdatePetName() throws Exception { + Pet pet7 = this.pets.findById(7); + String oldName = pet7.getName(); + + String newName = oldName + "X"; + pet7.setName(newName); + this.pets.save(pet7); + + pet7 = this.pets.findById(7); + assertThat(pet7.getName()).isEqualTo(newName); + } + + @Test + public void shouldFindVets() { + Collection vets = this.vets.findAll(); + + Vet vet = EntityUtils.getById(vets, Vet.class, 3); + assertThat(vet.getLastName()).isEqualTo("Douglas"); + assertThat(vet.getNrOfSpecialties()).isEqualTo(2); + assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry"); + assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery"); + } + + @Test + @Transactional + public void shouldAddNewVisitForPet() { + Pet pet7 = this.pets.findById(7); + int found = pet7.getVisits().size(); + Visit visit = new Visit(); + pet7.addVisit(visit); + visit.setDescription("test"); + this.visits.save(visit); + this.pets.save(pet7); + + pet7 = this.pets.findById(7); + assertThat(pet7.getVisits().size()).isEqualTo(found + 1); + assertThat(visit.getId()).isNotNull(); + } + + @Test + public void shouldFindVisitsByPetId() throws Exception { + Collection visits = this.visits.findByPetId(7); + assertThat(visits.size()).isEqualTo(2); + Visit[] visitArr = visits.toArray(new Visit[visits.size()]); + assertThat(visitArr[0].getDate()).isNotNull(); + assertThat(visitArr[0].getPetId()).isEqualTo(7); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java b/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java index 44dc6b1c2..ce83cc38c 100644 --- a/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java +++ b/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java @@ -1,54 +1,54 @@ -/* - * Copyright 2002-2013 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.samples.petclinic.service; - -import java.util.Collection; - -import org.springframework.orm.ObjectRetrievalFailureException; -import org.springframework.samples.petclinic.model.BaseEntity; - -/** - * Utility methods for handling entities. Separate from the BaseEntity class mainly because of dependency on the - * ORM-associated ObjectRetrievalFailureException. - * - * @author Juergen Hoeller - * @author Sam Brannen - * @see org.springframework.samples.petclinic.model.BaseEntity - * @since 29.10.2003 - */ -public abstract class EntityUtils { - - /** - * Look up the entity of the given class with the given id in the given collection. - * - * @param entities the collection to search - * @param entityClass the entity class to look up - * @param entityId the entity id to look up - * @return the found entity - * @throws ObjectRetrievalFailureException if the entity was not found - */ - public static T getById(Collection entities, Class entityClass, int entityId) - throws ObjectRetrievalFailureException { - for (T entity : entities) { - if (entity.getId() == entityId && entityClass.isInstance(entity)) { - return entity; - } - } - throw new ObjectRetrievalFailureException(entityClass, entityId); - } - -} +/* + * Copyright 2002-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.samples.petclinic.service; + +import java.util.Collection; + +import org.springframework.orm.ObjectRetrievalFailureException; +import org.springframework.samples.petclinic.model.BaseEntity; + +/** + * Utility methods for handling entities. Separate from the BaseEntity class mainly because of dependency on the + * ORM-associated ObjectRetrievalFailureException. + * + * @author Juergen Hoeller + * @author Sam Brannen + * @see org.springframework.samples.petclinic.model.BaseEntity + * @since 29.10.2003 + */ +public abstract class EntityUtils { + + /** + * Look up the entity of the given class with the given id in the given collection. + * + * @param entities the collection to search + * @param entityClass the entity class to look up + * @param entityId the entity id to look up + * @return the found entity + * @throws ObjectRetrievalFailureException if the entity was not found + */ + public static T getById(Collection entities, Class entityClass, int entityId) + throws ObjectRetrievalFailureException { + for (T entity : entities) { + if (entity.getId() == entityId && entityClass.isInstance(entity)) { + return entity; + } + } + throw new ObjectRetrievalFailureException(entityClass, entityId); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java index 3f108bfe9..5b6c5b130 100644 --- a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java @@ -1,38 +1,38 @@ -package org.springframework.samples.petclinic.system; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; - -/** - * Test class for {@link CrashController} - * - * @author Colin But - */ -@RunWith(SpringRunner.class) -// Waiting https://github.com/spring-projects/spring-boot/issues/5574 -@Ignore -@WebMvcTest(controllers = CrashController.class) -public class CrashControllerTests { - - @Autowired - private MockMvc mockMvc; - - @Test - public void testTriggerException() throws Exception { - mockMvc.perform(get("/oups")).andExpect(view().name("exception")) - .andExpect(model().attributeExists("exception")) - .andExpect(forwardedUrl("exception")).andExpect(status().isOk()); - } -} +package org.springframework.samples.petclinic.system; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +/** + * Test class for {@link CrashController} + * + * @author Colin But + */ +@RunWith(SpringRunner.class) +// Waiting https://github.com/spring-projects/spring-boot/issues/5574 +@Ignore +@WebMvcTest(controllers = CrashController.class) +public class CrashControllerTests { + + @Autowired + private MockMvc mockMvc; + + @Test + public void testTriggerException() throws Exception { + mockMvc.perform(get("/oups")).andExpect(view().name("exception")) + .andExpect(model().attributeExists("exception")) + .andExpect(forwardedUrl("exception")).andExpect(status().isOk()); + } +} diff --git a/src/test/java/org/springframework/samples/petclinic/system/ProductionConfigurationTests.java b/src/test/java/org/springframework/samples/petclinic/system/ProductionConfigurationTests.java index 9636e3623..ecbfd33cf 100644 --- a/src/test/java/org/springframework/samples/petclinic/system/ProductionConfigurationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/system/ProductionConfigurationTests.java @@ -1,23 +1,23 @@ -package org.springframework.samples.petclinic.system; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.samples.petclinic.vet.VetRepository; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class ProductionConfigurationTests { - - @Autowired - private VetRepository vets; - - @Test - public void testFindAll() throws Exception { - vets.findAll(); - vets.findAll(); // served from cache - } -} +package org.springframework.samples.petclinic.system; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.samples.petclinic.vet.VetRepository; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ProductionConfigurationTests { + + @Autowired + private VetRepository vets; + + @Test + public void testFindAll() throws Exception { + vets.findAll(); + vets.findAll(); // served from cache + } +} diff --git a/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java index ce6adf8e0..3035d8096 100644 --- a/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java @@ -1,82 +1,82 @@ -package org.springframework.samples.petclinic.vet; - -import static org.hamcrest.xml.HasXPath.hasXPath; -import static org.mockito.BDDMockito.given; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; - -import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.samples.petclinic.vet.Specialty; -import org.springframework.samples.petclinic.vet.Vet; -import org.springframework.samples.petclinic.vet.VetController; -import org.springframework.samples.petclinic.vet.VetRepository; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultActions; - -/** - * Test class for the {@link VetController} - */ -@RunWith(SpringRunner.class) -@WebMvcTest(VetController.class) -public class VetControllerTests { - - @Autowired - private MockMvc mockMvc; - - @MockBean - private VetRepository vets; - - @Before - public void setup() { - Vet james = new Vet(); - james.setFirstName("James"); - james.setLastName("Carter"); - james.setId(1); - Vet helen = new Vet(); - helen.setFirstName("Helen"); - helen.setLastName("Leary"); - helen.setId(2); - Specialty radiology = new Specialty(); - radiology.setId(1); - radiology.setName("radiology"); - helen.addSpecialty(radiology); - given(this.vets.findAll()).willReturn(Lists.newArrayList(james, helen)); - } - - @Test - public void testShowVetListHtml() throws Exception { - mockMvc.perform(get("/vets.html")) - .andExpect(status().isOk()) - .andExpect(model().attributeExists("vets")) - .andExpect(view().name("vets/vetList")); - } - - @Test - public void testShowResourcesVetList() throws Exception { - ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); - actions.andExpect(content().contentType("application/json;charset=UTF-8")) - .andExpect(jsonPath("$.vetList[0].id").value(1)); - } - - @Test - public void testShowVetListXml() throws Exception { - mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_XML_VALUE)) - .andExpect(content().node(hasXPath("/vets/vetList[id=1]/id"))); - } - -} +package org.springframework.samples.petclinic.vet; + +import static org.hamcrest.xml.HasXPath.hasXPath; +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + +import org.assertj.core.util.Lists; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.samples.petclinic.vet.Specialty; +import org.springframework.samples.petclinic.vet.Vet; +import org.springframework.samples.petclinic.vet.VetController; +import org.springframework.samples.petclinic.vet.VetRepository; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; + +/** + * Test class for the {@link VetController} + */ +@RunWith(SpringRunner.class) +@WebMvcTest(VetController.class) +public class VetControllerTests { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private VetRepository vets; + + @Before + public void setup() { + Vet james = new Vet(); + james.setFirstName("James"); + james.setLastName("Carter"); + james.setId(1); + Vet helen = new Vet(); + helen.setFirstName("Helen"); + helen.setLastName("Leary"); + helen.setId(2); + Specialty radiology = new Specialty(); + radiology.setId(1); + radiology.setName("radiology"); + helen.addSpecialty(radiology); + given(this.vets.findAll()).willReturn(Lists.newArrayList(james, helen)); + } + + @Test + public void testShowVetListHtml() throws Exception { + mockMvc.perform(get("/vets.html")) + .andExpect(status().isOk()) + .andExpect(model().attributeExists("vets")) + .andExpect(view().name("vets/vetList")); + } + + @Test + public void testShowResourcesVetList() throws Exception { + ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + actions.andExpect(content().contentType("application/json;charset=UTF-8")) + .andExpect(jsonPath("$.vetList[0].id").value(1)); + } + + @Test + public void testShowVetListXml() throws Exception { + mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_XML_VALUE)) + .andExpect(content().node(hasXPath("/vets/vetList[id=1]/id"))); + } + +} diff --git a/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java b/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java index de3a7b9bb..da79a52d1 100644 --- a/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java +++ b/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java @@ -1,43 +1,43 @@ -/* - * Copyright 2016-2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.samples.petclinic.vet; - -import org.junit.Test; - -import org.springframework.util.SerializationUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * - */ -public class VetTests { - - @Test - public void testSerialization() { - Vet vet = new Vet(); - vet.setFirstName("Zaphod"); - vet.setLastName("Beeblebrox"); - vet.setId(123); - Vet other = (Vet) SerializationUtils - .deserialize(SerializationUtils.serialize(vet)); - assertThat(other.getFirstName()).isEqualTo(vet.getFirstName()); - assertThat(other.getLastName()).isEqualTo(vet.getLastName()); - assertThat(other.getId()).isEqualTo(vet.getId()); - } - -} +/* + * Copyright 2016-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.samples.petclinic.vet; + +import org.junit.Test; + +import org.springframework.util.SerializationUtils; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Dave Syer + * + */ +public class VetTests { + + @Test + public void testSerialization() { + Vet vet = new Vet(); + vet.setFirstName("Zaphod"); + vet.setLastName("Beeblebrox"); + vet.setId(123); + Vet other = (Vet) SerializationUtils + .deserialize(SerializationUtils.serialize(vet)); + assertThat(other.getFirstName()).isEqualTo(vet.getFirstName()); + assertThat(other.getLastName()).isEqualTo(vet.getLastName()); + assertThat(other.getId()).isEqualTo(vet.getId()); + } + +} diff --git a/src/test/jmeter/petclinic_test_plan.jmx b/src/test/jmeter/petclinic_test_plan.jmx index 5e942b138..b9adf8849 100644 --- a/src/test/jmeter/petclinic_test_plan.jmx +++ b/src/test/jmeter/petclinic_test_plan.jmx @@ -1,411 +1,411 @@ - - - - - - false - false - - - - PETCLINIC_HOST - localhost - = - - - PETCLINIC_PORT - 8080 - = - - - CONTEXT_WEB - - = - - - - - - - - continue - - false - 10 - - 500 - 10 - 1361531541000 - 1361531541000 - false - - - true - Original : 500 - 10 - 10 - - - - 300 - - - - - - - ${PETCLINIC_HOST} - ${PETCLINIC_PORT} - - - - - - 4 - - - - - true - - - - 1 - 10 - 1 - count - - false - - - - 1 - 13 - 1 - petCount - - false - - - - - - - - - - - - - ${CONTEXT_WEB}/ - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/resources/css/petclinic.css - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/vendors/jquery/jquery.js - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/vets.html - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/owners/find.html - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/owners.html?lastName= - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/owners/${count}.html - GET - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/owners/${count}/edit.html - GET - true - false - true - false - false - - - - - true - - - - false - firstName=Test&lastName=${count}&address=1234+Test+St.&city=TestCity&telephone=612345678 - = - - - - - - - - - - ${CONTEXT_WEB}/owners/${count}/edit.html - POST - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new - GET - true - false - true - false - false - - - - - true - - - - false - date=2013%2F02%2F22&description=visit - = - - - - - - - - - - ${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new - POST - true - false - true - false - false - - - - - - - - - - - - - - ${CONTEXT_WEB}/owners/${count}.html - GET - true - false - true - false - false - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - false - false - false - false - false - 0 - true - true - - - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - false - false - false - false - false - 0 - true - true - - - - - - - - - + + + + + + false + false + + + + PETCLINIC_HOST + localhost + = + + + PETCLINIC_PORT + 8080 + = + + + CONTEXT_WEB + + = + + + + + + + + continue + + false + 10 + + 500 + 10 + 1361531541000 + 1361531541000 + false + + + true + Original : 500 - 10 - 10 + + + + 300 + + + + + + + ${PETCLINIC_HOST} + ${PETCLINIC_PORT} + + + + + + 4 + + + + + true + + + + 1 + 10 + 1 + count + + false + + + + 1 + 13 + 1 + petCount + + false + + + + + + + + + + + + + ${CONTEXT_WEB}/ + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/resources/css/petclinic.css + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/vendors/jquery/jquery.js + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/vets.html + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/find.html + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners.html?lastName= + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}.html + GET + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/edit.html + GET + true + false + true + false + false + + + + + true + + + + false + firstName=Test&lastName=${count}&address=1234+Test+St.&city=TestCity&telephone=612345678 + = + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/edit.html + POST + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new + GET + true + false + true + false + false + + + + + true + + + + false + date=2013%2F02%2F22&description=visit + = + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new + POST + true + false + true + false + false + + + + + + + + + + + + + + ${CONTEXT_WEB}/owners/${count}.html + GET + true + false + true + false + false + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + true + true + + + + + + + + + diff --git a/text.txt b/text.txt index a465ddff2..1504fd190 100644 --- a/text.txt +++ b/text.txt @@ -1 +1 @@ -austin messed up +austin messed up diff --git a/update.sh b/update.sh index 00740be2c..a8db5878a 100755 --- a/update.sh +++ b/update.sh @@ -1 +1 @@ -./kill.sh && git pull origin dev && ./run.sh & +./kill.sh && git pull origin master && ./run.sh &