This commit is contained in:
Austin-Mills 2017-06-23 15:10:03 +00:00 committed by GitHub
commit ec6b44cafd
103 changed files with 13131 additions and 13712 deletions

7
.gitignore vendored
View file

@ -6,3 +6,10 @@ target/*
*.iml
/target
_site/
.DS_Store
.log
.editorconfig
.springBeans
Servers
.metadata
bin

1
kidclinic Submodule

@ -0,0 +1 @@
Subproject commit f08660d47ba9b90d4416860808decf90768838e7

1
kill.sh Executable file
View file

@ -0,0 +1 @@
killall java

View file

@ -4,15 +4,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>spring-petclinic</artifactId>
<version>1.5.1</version>
<artifactId>kidclinic</artifactId>
<version>mvp</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<name>petclinic</name>
<name>kidclinic</name>
<properties>

129
readme.md
View file

@ -1,105 +1,52 @@
# 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/)
# GlowTouch KidClinic (built on Spring)
## Understanding the Spring Petclinic application with a few diagrams
<a href="https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application">See the presentation here</a>
## Running petclinic locally
```
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
## Running Kidclinic locally
```bash
git clone https://github.com/sasankglowtouch/kidclinic.git
cd kidclinic
./mvnw spring-boot:run
```
You can then access petclinic here: http://localhost:8080/
You can then access KidClinic here: http://localhost:8080/
<img width="1042" alt="petclinic-screenshot" src="https://cloud.githubusercontent.com/assets/838318/19727082/2aee6d6c-9b8e-11e6-81fe-e889a5ddfded.png">
## The Purpose of KidClinic
The purpose of KidClinic is to simulate the building of an enterprise application using Java and Spring. Being built off of Spring's PetClinic, KidClinic is used to understand the process of building an app in order to gain knowledge and make future development more efficient and successful.
## 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
## Current Features
- [x] Adding new parents and children
- [x] View current list of doctors and their specialities
- [x] Search through database of parents
### Adding parents and children
When viewing the parents page, users have an option of searching the parents database or adding a parent. Once a parent is chosen or added, a child can be added to that parent.
## Database configuration
## Upcoming Additions
| Addition | Stage of Development | Expected Development Time | Lead |
| :-------- | :-------------------- | :------------------------- | :--- |
| Login system | Research | Short Term | Emily |
| Updated child's information | Implementation | Immediate | Daniel |
| Google Map API integration | Research | Long Term | Austin |
| Add reviews section for doctors | Development | Short Term | Sasank |
| Calendar Scheduling | Research | Long Term | Sasank |
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.
### Login System
THe login system is meant to create three different views for users. There will be three categories of users: parents, nurses, and doctors. Each must login to view certain aspects of the website. Without the login system, the all the information of the parents is viewable without any security.
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 <http://editorconfig.org>.
#### How to incorporate the login system
In order to create a login system, we need to create a subfolder for the login controller. This follows [DoctorController.java](/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java) for the methods.
### Reviews section for Doctors
The reviews section is meant to show the location of the doctors and include a view reviews for each doctor.
#### How to incorporate the reviews
In order the create the reviews section, we must create a controller similar to [DoctorController.java](/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java). Then we need to add some reviews to the database as well as locations of each doctor. Then, using [Thymeleaf](http://www.thymeleaf.org/), we can display this information in [reviews.html](/src/main/resources/templates/reviews.html).
## Contact
If you are interested in the development of this app, you can contact any of the developers. You can reach us at
| Name | Email |
| :--- | :---- |
| Emily Liu | emily.liu@glowtouch.com |
| Austin Mills | austin.mills@glowtouch.com |
| Daniel Ryan | daniel.ryan@glowtouch.com |
| Sasank Vishnubhatla | sasank.vishnubhatla@glowtouch.com |

1
run.sh Executable file
View file

@ -0,0 +1 @@
./mvnw spring-boot:run &

View file

@ -14,22 +14,22 @@
* limitations under the License.
*/
package org.springframework.samples.petclinic;
package org.springframework.samples.kidclinic;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* PetClinic Spring Boot Application.
* KidClinic Spring Boot Application.
*
* @author Dave Syer
*
*/
@SpringBootApplication
public class PetClinicApplication {
public class KidClinicApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(PetClinicApplication.class, args);
SpringApplication.run(KidClinicApplication.class, args);
}
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.vet;
package org.springframework.samples.kidclinic.doctor;
import java.util.ArrayList;
import java.util.Collections;
@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
@ -29,9 +30,10 @@ import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator;
import org.springframework.samples.petclinic.model.Person;
import org.springframework.samples.kidclinic.model.Person;
/**
* Simple JavaBean domain object representing a veterinarian.
@ -42,13 +44,25 @@ import org.springframework.samples.petclinic.model.Person;
* @author Arjen Poutsma
*/
@Entity
@Table(name = "vets")
public class Vet extends Person {
@Table(name = "doctors")
public class Doctor extends Person {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
@JoinTable(name = "doctor_specialties", joinColumns = @JoinColumn(name = "doctor_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
private Set<Specialty> specialties;
@Column(name = "address")
@NotEmpty
private String address;
@Column(name = "city")
@NotEmpty
private String city;
@Column(name = "state")
@NotEmpty
private String state;
protected Set<Specialty> getSpecialtiesInternal() {
if (this.specialties == null) {
this.specialties = new HashSet<>();
@ -76,4 +90,28 @@ public class Vet extends Person {
getSpecialtiesInternal().add(specialty);
}
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 getState(){
return this.state;
}
public void setState(String state){
this.state = state;
}
}

View file

@ -0,0 +1,72 @@
/*
* 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<String, Object> 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 = { "/map.html" })
public String showDoctorLists(Map<String, Object> 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 "mapList";
}
@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;
}
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.vet;
package org.springframework.samples.kidclinic.doctor;
import java.util.Collection;
@ -23,7 +23,7 @@ import org.springframework.data.repository.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
* Repository class for <code>Vet</code> domain objects All method names are compliant with Spring Data naming
* Repository class for <code>Doctor</code> 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
@ -31,16 +31,16 @@ import org.springframework.transaction.annotation.Transactional;
* @author Sam Brannen
* @author Michael Isvy
*/
public interface VetRepository extends Repository<Vet, Integer> {
public interface DoctorRepository extends Repository<Doctor, Integer> {
/**
* Retrieve all <code>Vet</code>s from the data store.
* Retrieve all <code>Doctor</code>s from the data store.
*
* @return a <code>Collection</code> of <code>Vet</code>s
* @return a <code>Collection</code> of <code>Doctor</code>s
*/
@Transactional(readOnly = true)
@Cacheable("vets")
Collection<Vet> findAll() throws DataAccessException;
@Cacheable("doctors")
Collection<Doctor> findAll() throws DataAccessException;
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.vet;
package org.springframework.samples.kidclinic.doctor;
import java.util.ArrayList;
import java.util.List;
@ -22,22 +22,22 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Simple domain object representing a list of veterinarians. Mostly here to be used for the 'vets' {@link
* 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 Vets {
public class Doctors {
private List<Vet> vets;
private List<Doctor> doctors;
@XmlElement
public List<Vet> getVetList() {
if (vets == null) {
vets = new ArrayList<>();
public List<Doctor> getDoctorList() {
if (doctors == null) {
doctors = new ArrayList<>();
}
return vets;
return doctors;
}
}

View file

@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.vet;
package org.springframework.samples.kidclinic.doctor;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.springframework.samples.petclinic.model.NamedEntity;
import org.springframework.samples.kidclinic.model.NamedEntity;
/**
* Models a {@link Vet Vet's} specialty (for example, dentistry).
* Models a {@link Doctor Doctor's} specialty (for example, dentistry).
*
* @author Juergen Hoeller
*/

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.model;
package org.springframework.samples.kidclinic.model;
import java.io.Serializable;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.model;
package org.springframework.samples.kidclinic.model;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.model;
package org.springframework.samples.kidclinic.model;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

View file

@ -1,5 +1,5 @@
/**
* The classes in this package represent utilities used by the domain.
*/
package org.springframework.samples.petclinic.model;
package org.springframework.samples.kidclinic.model;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import java.util.ArrayList;
import java.util.Collections;
@ -37,8 +37,8 @@ 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.petclinic.model.NamedEntity;
import org.springframework.samples.petclinic.visit.Visit;
import org.springframework.samples.kidclinic.model.NamedEntity;
import org.springframework.samples.kidclinic.visit.Visit;
/**
* Simple business object representing a pet.
@ -48,8 +48,8 @@ import org.springframework.samples.petclinic.visit.Visit;
* @author Sam Brannen
*/
@Entity
@Table(name = "pets")
public class Pet extends NamedEntity {
@Table(name = "kids")
public class Kid extends NamedEntity {
@Column(name = "birth_date")
@Temporal(TemporalType.DATE)
@ -57,14 +57,20 @@ public class Pet extends NamedEntity {
private Date birthDate;
@ManyToOne
@JoinColumn(name = "type_id")
private PetType type;
@JoinColumn(name = "gender_id")
private KidGender gender;
@ManyToOne
@JoinColumn(name = "owner_id")
private Owner owner;
@JoinColumn(name = "parent_id")
private Parent parent;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "petId", fetch = FetchType.EAGER)
@Column(name = "allergies")
private String allergies;
@Column(name = "medications")
private String medications;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "kidId", fetch = FetchType.EAGER)
private Set<Visit> visits = new LinkedHashSet<>();
public void setBirthDate(Date birthDate) {
@ -75,20 +81,36 @@ public class Pet extends NamedEntity {
return this.birthDate;
}
public PetType getType() {
return this.type;
public KidGender getGender() {
return this.gender;
}
public void setType(PetType type) {
this.type = type;
public void setGender(KidGender gender) {
this.gender = gender;
}
public Owner getOwner() {
return this.owner;
public Parent getParent() {
return this.parent;
}
protected void setOwner(Owner owner) {
this.owner = owner;
protected void setParent(Parent parent) {
this.parent = parent;
}
public String getAllergies(){
return this.allergies;
}
public void setAllergies(String allergies){
this.allergies = allergies;
}
public String getMedications(){
return this.medications;
}
public void setMedications(String medications){
this.medications = medications;
}
protected Set<Visit> getVisitsInternal() {
@ -111,7 +133,7 @@ public class Pet extends NamedEntity {
public void addVisit(Visit visit) {
getVisitsInternal().add(visit);
visit.setPetId(this.getId());
visit.setKidId(this.getId());
}
}

View file

@ -0,0 +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<KidGender> 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}";
}
}
}

View file

@ -13,19 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.springframework.samples.petclinic.model.NamedEntity;
import org.springframework.samples.kidclinic.model.NamedEntity;
/**
* @author Juergen Hoeller
* Can be Cat, Dog, Hamster...
*/
@Entity
@Table(name = "types")
public class PetType extends NamedEntity {
@Table(name = "gender")
public class KidGender extends NamedEntity {
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import java.text.ParseException;
@ -25,7 +25,7 @@ import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;
/**
* Instructs Spring MVC on how to parse and print elements of type 'PetType'. Starting from Spring 3.0, Formatters have
* 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/
@ -36,30 +36,30 @@ import org.springframework.stereotype.Component;
* @author Michael Isvy
*/
@Component
public class PetTypeFormatter implements Formatter<PetType> {
public class KidGenderFormatter implements Formatter<KidGender> {
private final PetRepository pets;
private final KidRepository kids;
@Autowired
public PetTypeFormatter(PetRepository pets) {
this.pets = pets;
public KidGenderFormatter(KidRepository kids) {
this.kids = kids;
}
@Override
public String print(PetType petType, Locale locale) {
return petType.getName();
public String print(KidGender kidGender, Locale locale) {
return kidGender.getName();
}
@Override
public PetType parse(String text, Locale locale) throws ParseException {
Collection<PetType> findPetTypes = this.pets.findPetTypes();
for (PetType type : findPetTypes) {
if (type.getName().equals(text)) {
return type;
public KidGender parse(String text, Locale locale) throws ParseException {
Collection<KidGender> findKidGenders = this.kids.findKidGenders();
for (KidGender gender : findKidGenders) {
if (gender.getName().equals(text)) {
return gender;
}
}
throw new ParseException("type not found: " + text, 0);
throw new ParseException("gender not found: " + text, 0);
}
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import java.util.List;
@ -22,7 +22,7 @@ import org.springframework.data.repository.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
* Repository class for <code>Pet</code> domain objects All method names are compliant with Spring Data naming
* Repository class for <code>Kid</code> 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
@ -30,29 +30,29 @@ import org.springframework.transaction.annotation.Transactional;
* @author Sam Brannen
* @author Michael Isvy
*/
public interface PetRepository extends Repository<Pet, Integer> {
public interface KidRepository extends Repository<Kid, Integer> {
/**
* Retrieve all {@link PetType}s from the data store.
* @return a Collection of {@link PetType}s.
* Retrieve all {@link KidGender}s from the data store.
* @return a Collection of {@link KidGender}s.
*/
@Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
@Query("SELECT ptype FROM KidGender ptype ORDER BY ptype.name")
@Transactional(readOnly = true)
List<PetType> findPetTypes();
List<KidGender> findKidGenders();
/**
* Retrieve a {@link Pet} from the data store by id.
* Retrieve a {@link Kid} from the data store by id.
* @param id the id to search for
* @return the {@link Pet} if found
* @return the {@link Kid} if found
*/
@Transactional(readOnly = true)
Pet findById(Integer id);
Kid findById(Integer id);
/**
* Save a {@link Pet} to the data store, either inserting or updating it.
* @param pet the {@link Pet} to save
* Save a {@link Kid} to the data store, either inserting or updating it.
* @param kid the {@link Kid} to save
*/
void save(Pet pet);
void save(Kid kid);
}

View file

@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
/**
* <code>Validator</code> for <code>Pet</code> forms.
* <code>Validator</code> for <code>Kid</code> forms.
* <p>
* We're not using Bean Validation annotations here because it is easier to define such validation rule in Java.
* </p>
@ -28,36 +28,48 @@ import org.springframework.validation.Validator;
* @author Ken Krebs
* @author Juergen Hoeller
*/
public class PetValidator implements Validator {
public class KidValidator implements Validator {
private static final String REQUIRED = "required";
@Override
public void validate(Object obj, Errors errors) {
Pet pet = (Pet) obj;
String name = pet.getName();
Kid kid = (Kid) obj;
String name = kid.getName();
String medications = kid.getMedications();
String allergies = kid.getAllergies();
// name validation
if (!StringUtils.hasLength(name)) {
errors.rejectValue("name", REQUIRED, REQUIRED);
}
// type validation
if (pet.isNew() && pet.getType() == null) {
errors.rejectValue("type", REQUIRED, REQUIRED);
// allergies validation
if (!StringUtils.hasLength(allergies)) {
errors.rejectValue("allergies", REQUIRED, REQUIRED);
}
// medications validation
if (!StringUtils.hasLength(medications)) {
errors.rejectValue("medications", REQUIRED, REQUIRED);
}
if (kid.isNew() && kid.getGender() == null) {
errors.rejectValue("gender", REQUIRED, REQUIRED);
}
// birth date validation
if (pet.getBirthDate() == null) {
if (kid.getBirthDate() == null) {
errors.rejectValue("birthDate", REQUIRED, REQUIRED);
}
}
/**
* This Validator validates *just* Pet instances
* This Validator validates *just* Kid instances
*/
@Override
public boolean supports(Class<?> clazz) {
return Pet.class.isAssignableFrom(clazz);
return Kid.class.isAssignableFrom(clazz);
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import java.util.ArrayList;
import java.util.Collections;
@ -32,10 +32,10 @@ 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.petclinic.model.Person;
import org.springframework.samples.kidclinic.model.Person;
/**
* Simple JavaBean domain object representing an owner.
* Simple JavaBean domain object representing an parent.
*
* @author Ken Krebs
* @author Juergen Hoeller
@ -43,8 +43,8 @@ import org.springframework.samples.petclinic.model.Person;
* @author Michael Isvy
*/
@Entity
@Table(name = "owners")
public class Owner extends Person {
@Table(name = "parents")
public class Parent extends Person {
@Column(name = "address")
@NotEmpty
private String address;
@ -53,13 +53,17 @@ public class Owner extends Person {
@NotEmpty
private String city;
@Column(name = "state")
@NotEmpty
private String state;
@Column(name = "telephone")
@NotEmpty
@Digits(fraction = 0, integer = 10)
private String telephone;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parent")
private Set<Kid> kids;
public String getAddress() {
@ -78,6 +82,14 @@ public class Owner extends Person {
this.city = city;
}
public String getState(){
return this.state;
}
public void setState(String state){
this.state = state;
}
public String getTelephone() {
return this.telephone;
}
@ -86,54 +98,54 @@ public class Owner extends Person {
this.telephone = telephone;
}
protected Set<Pet> getPetsInternal() {
if (this.pets == null) {
this.pets = new HashSet<>();
protected Set<Kid> getKidsInternal() {
if (this.kids == null) {
this.kids = new HashSet<>();
}
return this.pets;
return this.kids;
}
protected void setPetsInternal(Set<Pet> pets) {
this.pets = pets;
protected void setKidsInternal(Set<Kid> kids) {
this.kids = kids;
}
public List<Pet> getPets() {
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
return Collections.unmodifiableList(sortedPets);
public List<Kid> getKids() {
List<Kid> sortedKids = new ArrayList<>(getKidsInternal());
PropertyComparator.sort(sortedKids, new MutableSortDefinition("name", true, true));
return Collections.unmodifiableList(sortedKids);
}
public void addPet(Pet pet) {
if (pet.isNew()) {
getPetsInternal().add(pet);
public void addKid(Kid kid) {
if (kid.isNew()) {
getKidsInternal().add(kid);
}
pet.setOwner(this);
kid.setParent(this);
}
/**
* Return the Pet with the given name, or null if none found for this Owner.
* Return the Kid with the given name, or null if none found for this Parent.
*
* @param name to test
* @return true if pet name is already in use
* @return true if kid name is already in use
*/
public Pet getPet(String name) {
return getPet(name, false);
public Kid getKid(String name) {
return getKid(name, false);
}
/**
* Return the Pet with the given name, or null if none found for this Owner.
* Return the Kid with the given name, or null if none found for this Kid.
*
* @param name to test
* @return true if pet name is already in use
* @return true if kid name is already in use
*/
public Pet getPet(String name, boolean ignoreNew) {
public Kid getKid(String name, boolean ignoreNew) {
name = name.toLowerCase();
for (Pet pet : getPetsInternal()) {
if (!ignoreNew || !pet.isNew()) {
String compName = pet.getName();
for (Kid kid : getKidsInternal()) {
if (!ignoreNew || !kid.isNew()) {
String compName = kid.getName();
compName = compName.toLowerCase();
if (compName.equals(name)) {
return pet;
return kid;
}
}
}

View file

@ -0,0 +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<String, Object> 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<String, Object> model) {
model.put("parent", new Parent());
return "parents/findParents";
}
@RequestMapping(value = "/parents", method = RequestMethod.GET)
public String processFindForm(Parent parent, BindingResult result, Map<String, Object> 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<Parent> 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;
}
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
package org.springframework.samples.kidclinic.parent;
import java.util.Collection;
@ -23,7 +23,7 @@ import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
/**
* Repository class for <code>Owner</code> domain objects All method names are compliant with Spring Data naming
* Repository class for <code>Parent</code> 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
@ -31,33 +31,33 @@ import org.springframework.transaction.annotation.Transactional;
* @author Sam Brannen
* @author Michael Isvy
*/
public interface OwnerRepository extends Repository<Owner, Integer> {
public interface ParentRepository extends Repository<Parent, Integer> {
/**
* Retrieve {@link Owner}s from the data store by last name, returning all owners
* Retrieve {@link Parent}s from the data store by last name, returning all parents
* whose last name <i>starts</i> with the given name.
* @param lastName Value to search for
* @return a Collection of matching {@link Owner}s (or an empty Collection if none
* @return a Collection of matching {@link Parent}s (or an empty Collection if none
* found)
*/
@Query("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName LIKE :lastName%")
@Query("SELECT DISTINCT parent FROM Parent parent left join fetch parent.kids WHERE parent.lastName LIKE :lastName%")
@Transactional(readOnly = true)
Collection<Owner> findByLastName(@Param("lastName") String lastName);
Collection<Parent> findByLastName(@Param("lastName") String lastName);
/**
* Retrieve an {@link Owner} from the data store by id.
* Retrieve an {@link Parent} from the data store by id.
* @param id the id to search for
* @return the {@link Owner} if found
* @return the {@link Parent} if found
*/
@Query("SELECT owner FROM Owner owner left join fetch owner.pets WHERE owner.id =:id")
@Query("SELECT parent FROM Parent parent left join fetch parent.kids WHERE parent.id =:id")
@Transactional(readOnly = true)
Owner findById(@Param("id") Integer id);
Parent findById(@Param("id") Integer id);
/**
* Save an {@link Owner} to the data store, either inserting or updating it.
* @param owner the {@link Owner} to save
* Save an {@link Parent} to the data store, either inserting or updating it.
* @param owner the {@link Parent} to save
*/
void save(Owner owner);
void save(Parent parent);
}

View file

@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.owner;
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.petclinic.visit.Visit;
import org.springframework.samples.petclinic.visit.VisitRepository;
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;
@ -42,13 +42,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
class VisitController {
private final VisitRepository visits;
private final PetRepository pets;
private final KidRepository kids;
@Autowired
public VisitController(VisitRepository visits, PetRepository pets) {
public VisitController(VisitRepository visits, KidRepository kids) {
this.visits = visits;
this.pets = pets;
this.kids = kids;
}
@InitBinder
@ -60,35 +60,35 @@ class VisitController {
* 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 Pet object always has an id
* - 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 petId
* @return Pet
* @param kidId
* @return Kid
*/
@ModelAttribute("visit")
public Visit loadPetWithVisit(@PathVariable("petId") int petId, Map<String, Object> model) {
Pet pet = this.pets.findById(petId);
model.put("pet", pet);
public Visit loadKidWithVisit(@PathVariable("kidId") int kidId, Map<String, Object> model) {
Kid kid = this.kids.findById(kidId);
model.put("kid", kid);
Visit visit = new Visit();
pet.addVisit(visit);
kid.addVisit(visit);
return visit;
}
// Spring MVC calls method loadPetWithVisit(...) before initNewVisitForm is called
@RequestMapping(value = "/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET)
public String initNewVisitForm(@PathVariable("petId") int petId, Map<String, Object> model) {
return "pets/createOrUpdateVisitForm";
// 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<String, Object> model) {
return "kids/createOrUpdateVisitForm";
}
// Spring MVC calls method loadPetWithVisit(...) before processNewVisitForm is called
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/visits/new", method = RequestMethod.POST)
// 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 "pets/createOrUpdateVisitForm";
return "kids/createOrUpdateVisitForm";
} else {
this.visits.save(visit);
return "redirect:/owners/{ownerId}";
return "redirect:/parents/{parentId}";
}
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.vet;
package org.springframework.samples.kidclinic.reviews;
import java.util.Map;
@ -29,32 +29,17 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author Arjen Poutsma
*/
@Controller
class VetController {
private final VetRepository vets;
class ReviewsController {
@Autowired
public VetController(VetRepository clinicService) {
this.vets = clinicService;
public ReviewsController() {
}
@RequestMapping(value = { "/vets.html" })
public String showVetList(Map<String, Object> model) {
// Here we are returning an object of type 'Vets' rather than a collection of Vet
@RequestMapping(value = { "/reviews.html" })
public String showReviews(Map<String, Object> 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
Vets vets = new Vets();
vets.getVetList().addAll(this.vets.findAll());
model.put("vets", vets);
return "vets/vetList";
}
@RequestMapping(value = { "/vets.json", "/vets.xml" })
public @ResponseBody Vets showResourcesVetList() {
// Here we are returning an object of type 'Vets' rather than a collection of Vet
// objects so it is simpler for JSon/Object mapping
Vets vets = new Vets();
vets.getVetList().addAll(this.vets.findAll());
return vets;
return "reviews";
}
}

View file

@ -1,4 +1,4 @@
package org.springframework.samples.petclinic.system;
package org.springframework.samples.kidclinic.system;
import javax.cache.configuration.Configuration;
import javax.cache.configuration.MutableConfiguration;
@ -20,7 +20,7 @@ class CacheConfig {
public JCacheManagerCustomizer cacheManagerCustomizer() {
return cm -> {
Configuration<Object, Object> cacheConfiguration = createCacheConfiguration();
cm.createCache("vets", cacheConfiguration);
cm.createCache("doctors", cacheConfiguration);
};
}

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.system;
package org.springframework.samples.kidclinic.system;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@Controller
class CrashController {
@RequestMapping(value = "/oups", method = RequestMethod.GET)
@RequestMapping(value = "/oops", method = RequestMethod.GET)
public String triggerException() {
throw new RuntimeException(
"Expected: controller used to showcase what " + "happens when an exception is thrown");

View file

@ -1,4 +1,4 @@
package org.springframework.samples.petclinic.system;
package org.springframework.samples.kidclinic.system;
import org.springframework.stereotype.Controller;

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.visit;
package org.springframework.samples.kidclinic.visit;
import java.util.Date;
@ -25,7 +25,7 @@ import javax.persistence.TemporalType;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.BaseEntity;
import org.springframework.samples.kidclinic.model.BaseEntity;
/**
* Simple JavaBean domain object representing a visit.
@ -55,8 +55,8 @@ public class Visit extends BaseEntity {
/**
* Holds value of property pet.
*/
@Column(name = "pet_id")
private Integer petId;
@Column(name = "kid_id")
private Integer kidId;
/**
@ -104,21 +104,21 @@ public class Visit extends BaseEntity {
}
/**
* Getter for property pet id.
* Getter for property kid id.
*
* @return Value of property pet id.
* @return Value of property kid id.
*/
public Integer getPetId() {
return this.petId;
public Integer getKidId() {
return this.kidId;
}
/**
* Setter for property pet id.
* Setter for property kid id.
*
* @param petId New value of property pet id.
* @param petId New value of property kid id.
*/
public void setPetId(Integer petId) {
this.petId = petId;
public void setKidId(Integer kidId) {
this.kidId = kidId;
}
}

View file

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.visit;
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.petclinic.model.BaseEntity;
import org.springframework.samples.kidclinic.model.BaseEntity;
/**
* Repository class for <code>Visit</code> domain objects All method names are compliant with Spring Data naming
@ -40,6 +40,6 @@ public interface VisitRepository extends Repository<Visit, Integer> {
*/
void save(Visit visit) throws DataAccessException;
List<Visit> findByPetId(Integer petId);
List<Visit> findByKidId(Integer kidId);
}

View file

@ -1,136 +0,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.petclinic.owner;
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 OwnerController {
private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";
private final OwnerRepository owners;
@Autowired
public OwnerController(OwnerRepository clinicService) {
this.owners = clinicService;
}
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
@RequestMapping(value = "/owners/new", method = RequestMethod.GET)
public String initCreationForm(Map<String, Object> model) {
Owner owner = new Owner();
model.put("owner", owner);
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
}
@RequestMapping(value = "/owners/new", method = RequestMethod.POST)
public String processCreationForm(@Valid Owner owner, BindingResult result) {
if (result.hasErrors()) {
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
} else {
this.owners.save(owner);
return "redirect:/owners/" + owner.getId();
}
}
@RequestMapping(value = "/owners/find", method = RequestMethod.GET)
public String initFindForm(Map<String, Object> model) {
model.put("owner", new Owner());
return "owners/findOwners";
}
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {
// allow parameterless GET request for /owners to return all records
if (owner.getLastName() == null) {
owner.setLastName(""); // empty string signifies broadest possible search
}
// find owners by last name
Collection<Owner> results = this.owners.findByLastName(owner.getLastName());
if (results.isEmpty()) {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
return "owners/findOwners";
} else if (results.size() == 1) {
// 1 owner found
owner = results.iterator().next();
return "redirect:/owners/" + owner.getId();
} else {
// multiple owners found
model.put("selections", results);
return "owners/ownersList";
}
}
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.GET)
public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
Owner owner = this.owners.findById(ownerId);
model.addAttribute(owner);
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
}
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.POST)
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, @PathVariable("ownerId") int ownerId) {
if (result.hasErrors()) {
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
} else {
owner.setId(ownerId);
this.owners.save(owner);
return "redirect:/owners/{ownerId}";
}
}
/**
* Custom handler for displaying an owner.
*
* @param ownerId the ID of the owner to display
* @return a ModelMap with the model attributes for the view
*/
@RequestMapping("/owners/{ownerId}")
public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
ModelAndView mav = new ModelAndView("owners/ownerDetails");
mav.addObject(this.owners.findById(ownerId));
return mav;
}
}

View file

@ -1,116 +0,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.petclinic.owner;
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("/owners/{ownerId}")
class PetController {
private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm";
private final PetRepository pets;
private final OwnerRepository owners;
@Autowired
public PetController(PetRepository pets, OwnerRepository owners) {
this.pets = pets;
this.owners = owners;
}
@ModelAttribute("types")
public Collection<PetType> populatePetTypes() {
return this.pets.findPetTypes();
}
@ModelAttribute("owner")
public Owner findOwner(@PathVariable("ownerId") int ownerId) {
return this.owners.findById(ownerId);
}
@InitBinder("owner")
public void initOwnerBinder(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
@InitBinder("pet")
public void initPetBinder(WebDataBinder dataBinder) {
dataBinder.setValidator(new PetValidator());
}
@RequestMapping(value = "/pets/new", method = RequestMethod.GET)
public String initCreationForm(Owner owner, ModelMap model) {
Pet pet = new Pet();
owner.addPet(pet);
model.put("pet", pet);
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
}
@RequestMapping(value = "/pets/new", method = RequestMethod.POST)
public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model) {
if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null){
result.rejectValue("name", "duplicate", "already exists");
}
if (result.hasErrors()) {
model.put("pet", pet);
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
} else {
owner.addPet(pet);
this.pets.save(pet);
return "redirect:/owners/{ownerId}";
}
}
@RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.GET)
public String initUpdateForm(@PathVariable("petId") int petId, ModelMap model) {
Pet pet = this.pets.findById(petId);
model.put("pet", pet);
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
}
@RequestMapping(value = "/pets/{petId}/edit", method = RequestMethod.POST)
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model) {
if (result.hasErrors()) {
pet.setOwner(owner);
model.put("pet", pet);
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
} else {
owner.addPet(pet);
this.pets.save(pet);
return "redirect:/owners/{ownerId}";
}
}
}

View file

@ -1,12 +1,16 @@
.navbar {
border-top: 4px solid #6db33f;
background-color: #34302d;
margin-bottom: 0px;
//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;
@ -27,6 +31,7 @@
-webkit-transition: opacity 0.12s ease-in-out;
-o-transition: opacity 0.12s ease-in-out;
}
*/
.navbar a:hover.navbar-brand span {
opacity: 1;

View file

@ -13,20 +13,20 @@
*/
@icon-font-path: "../../webjars/bootstrap/fonts/";
@spring-green: #6db33f;
@spring-dark-green: #5fa134;
@spring-green: #4286f4;
@spring-dark-green: #2733ad;
@spring-brown: #34302D;
@spring-grey: #838789;
@spring-light-grey: #f1f1f1;
@body-bg: @spring-light-grey;
@body-bg: transparent;
@text-color: @spring-brown;
@link-color: @spring-dark-green;
@link-hover-color: @spring-dark-green;
@navbar-default-link-color: @spring-light-grey;
@navbar-default-link-active-color: @spring-light-grey;
@navbar-default-link-hover-color: @spring-light-grey;
@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;
@ -54,6 +54,26 @@
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;
@ -83,7 +103,25 @@
.container .text-muted {
margin: 20px 0;
//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 {
@ -91,16 +129,193 @@ code {
}
.xd-container {
margin-top: 40px;
margin-bottom: 100px;
padding-left: 5px;
padding-right: 5px;
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;
@ -112,9 +327,9 @@ h1 {
}
#job-params-modal .modal-dialog {
width: 90%;
margin-left:auto;
margin-right:auto;
width: 100%;
//margin-left:auto;
//margin-right:auto;
}
[ng-cloak].splash {
@ -156,9 +371,40 @@ table td.action-column {
.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 {

View file

@ -5,7 +5,7 @@
left:0px;
top:0px;
}
.navbar-collapse {width:100%}
.navbar a.navbar-brand {
display: block;
margin: 0 auto 0 auto;
@ -19,7 +19,15 @@
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;
}
@ -30,7 +38,7 @@
.xd-container {
margin-top: 20px;
margin-bottom: 30px;
//margin-bottom: 30px;
}
.index-page--subtitle {

View file

@ -24,8 +24,8 @@
body, h1, h2, h3, p, input {
margin: 0;
font-weight: 400;
font-family: "varela_roundregular", sans-serif;
color: #34302d;
font-family: "Bookman Old Style";
color: #0000;
}
h1 {

View file

@ -24,3 +24,5 @@ logging.level.org.springframework=INFO
# Active Spring profiles
spring.profiles.active=production
# Port

View file

@ -1,15 +1,18 @@
|\ _,,,--,,_
/,`.-'`' ._ \-;;,_
_______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______
| | '---''(_/._)-'(_\_) | | | | | | | | |
| _ | ___|_ _| | | | | |_| | | | __ _ _
| |_| | |___ | | | | | | | | | | \ \ \ \
| ___| ___| | | | _| |___| | _ | | _| \ \ \ \
| | | |___ | | | |_| | | | | | | |_ ) ) ) )
|___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
==================================================================/_/_/_/
Presenting...
_ __ _ _ _____ _ _ _
| | / /(_) | |/ __ \| |(_) (_)
| |/ / _ __| || / \/| | _ _ __ _ ___
| \ | | / _` || | | || || '_ \ | | / __|
| |\ \| || (_| || \__/\| || || | | || || (__
\_| \_/|_| \__,_| \____/|_||_||_| |_||_| \___|
:: Built with Spring Boot :: ${spring-boot.version}
:: Made with ♥ by the 2017 GlowTouch Technologies Interns ::
Enjoy...

View file

@ -1,53 +1,50 @@
INSERT INTO vets VALUES (1, 'James', 'Carter');
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
INSERT INTO doctors VALUES (1, 'James', 'Carter', '3424 University Ave.', 'Madison', 'WI');
INSERT INTO doctors VALUES (2, 'Helen', 'Leary', '750 Hilldale Way', 'Madison', 'WI');
INSERT INTO doctors VALUES (3, 'Linda', 'Douglas', '6136 University Ave.', 'Middleton', 'WI');
INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega', '8300 Airport Rd.', 'Middleton', 'WI');
INSERT INTO doctors VALUES (5, 'Henry', 'Stevens', '876 Jupiter Dr.', 'Madison', 'WI');
INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins', '4905 Monona Dr.', 'Monona', 'WI');
INSERT INTO specialties VALUES (1, 'radiology');
INSERT INTO specialties VALUES (2, 'surgery');
INSERT INTO specialties VALUES (3, 'dentistry');
INSERT INTO vet_specialties VALUES (2, 1);
INSERT INTO vet_specialties VALUES (3, 2);
INSERT INTO vet_specialties VALUES (3, 3);
INSERT INTO vet_specialties VALUES (4, 2);
INSERT INTO vet_specialties VALUES (5, 1);
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 types VALUES (1, 'cat');
INSERT INTO types VALUES (2, 'dog');
INSERT INTO types VALUES (3, 'lizard');
INSERT INTO types VALUES (4, 'snake');
INSERT INTO types VALUES (5, 'bird');
INSERT INTO types VALUES (6, 'hamster');
INSERT INTO gender VALUES (1, 'Male');
INSERT INTO gender VALUES (2, 'Female');
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1);
INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2);
INSERT INTO pets VALUES (3, 'Rosy', '2011-04-17', 2, 3);
INSERT INTO pets VALUES (4, 'Jewel', '2010-03-07', 2, 3);
INSERT INTO pets VALUES (5, 'Iggy', '2010-11-30', 3, 4);
INSERT INTO pets VALUES (6, 'George', '2010-01-20', 4, 5);
INSERT INTO pets VALUES (7, 'Samantha', '2012-09-04', 1, 6);
INSERT INTO pets VALUES (8, 'Max', '2012-09-04', 1, 6);
INSERT INTO pets VALUES (9, 'Lucky', '2011-08-06', 5, 7);
INSERT INTO pets VALUES (10, 'Mulligan', '2007-02-24', 2, 8);
INSERT INTO pets VALUES (11, 'Freddy', '2010-03-09', 5, 9);
INSERT INTO pets VALUES (12, 'Lucky', '2010-06-24', 2, 10);
INSERT INTO pets VALUES (13, 'Sly', '2012-06-08', 1, 10);
INSERT INTO parents VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', 'WI', '6085551023');
INSERT INTO parents VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', 'WI', '6085551749');
INSERT INTO parents VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', 'AZ', '6085558763');
INSERT INTO parents VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', 'CO', '6085553198');
INSERT INTO parents VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', 'WI', '6085552765');
INSERT INTO parents VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', 'WI', '6085552654');
INSERT INTO parents VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', 'WI', '6085555387');
INSERT INTO parents VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', 'WI', '6085557683');
INSERT INTO parents VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', 'WI', '6085559435');
INSERT INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', 'WI', '6085555487');
INSERT INTO kids VALUES (1, 'Alyssa', '2000-09-07', 2, 1, 'Claritin', 'None');
INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2, 'None', 'Lipitor');
INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3, 'None', 'None');
INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3, 'Penicilin', 'None');
INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4, 'None', 'Plavix');
INSERT INTO kids VALUES (6, 'Samantha', '2000-01-20', 2, 5, 'Latex', 'Advair Diskus');
INSERT INTO kids VALUES (7, 'George', '1995-09-04', 1, 6, 'Insulin', 'None');
INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6, 'None', 'Singulair');
INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7, 'None', 'Actos');
INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8, 'None', 'None');
INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9, 'Iodine', 'None');
INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10, 'None', 'None');
INSERT INTO kids VALUES (13, 'Conner', '2002-06-08', 1, 10, 'None', 'Epogen');
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', 'neutered');
INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed');
INSERT INTO visits VALUES (3, 8, '2013-01-03', 'cold');
INSERT INTO visits VALUES (4, 7, '2013-01-04', 'flu');

View file

@ -1,18 +1,21 @@
DROP TABLE vet_specialties IF EXISTS;
DROP TABLE vets IF EXISTS;
DROP TABLE doctor_specialties IF EXISTS;
DROP TABLE doctors IF EXISTS;
DROP TABLE specialties IF EXISTS;
DROP TABLE visits IF EXISTS;
DROP TABLE pets IF EXISTS;
DROP TABLE types IF EXISTS;
DROP TABLE owners IF EXISTS;
DROP TABLE kids IF EXISTS;
DROP TABLE gender IF EXISTS;
DROP TABLE parents IF EXISTS;
CREATE TABLE vets (
CREATE TABLE doctors (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)
last_name VARCHAR(30),
address VARCHAR(255),
city VARCHAR(80),
state VARCHAR(80)
);
CREATE INDEX vets_last_name ON vets (last_name);
CREATE INDEX doctors_last_name ON doctors (last_name);
CREATE TABLE specialties (
id INTEGER IDENTITY PRIMARY KEY,
@ -20,45 +23,48 @@ CREATE TABLE specialties (
);
CREATE INDEX specialties_name ON specialties (name);
CREATE TABLE vet_specialties (
vet_id INTEGER NOT NULL,
CREATE TABLE doctor_specialties (
doctor_id INTEGER NOT NULL,
specialty_id INTEGER NOT NULL
);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id);
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 types (
CREATE TABLE gender (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX types_name ON types (name);
CREATE INDEX gender_name ON gender (name);
CREATE TABLE owners (
CREATE TABLE parents (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR_IGNORECASE(30),
address VARCHAR(255),
city VARCHAR(80),
state VARCHAR(30),
telephone VARCHAR(20)
);
CREATE INDEX owners_last_name ON owners (last_name);
CREATE INDEX parents_last_name ON parents (last_name);
CREATE TABLE pets (
CREATE TABLE kids (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(30),
birth_date DATE,
type_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
gender_id INTEGER NOT NULL,
parent_id INTEGER NOT NULL,
allergies VARCHAR(255),
medications VARCHAR(255)
);
ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id);
ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id);
CREATE INDEX pets_name ON pets (name);
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,
pet_id INTEGER NOT NULL,
kid_id INTEGER NOT NULL,
visit_date DATE,
description VARCHAR(255)
);
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id);
CREATE INDEX visits_pet_id ON visits (pet_id);
ALTER TABLE visits ADD CONSTRAINT fk_visits_kids FOREIGN KEY (kid_id) REFERENCES kids (id);
CREATE INDEX visits_kid_id ON visits (kid_id);

View file

@ -1,51 +1,47 @@
INSERT IGNORE INTO vets VALUES (1, 'James', 'Carter');
INSERT IGNORE INTO vets VALUES (2, 'Helen', 'Leary');
INSERT IGNORE INTO vets VALUES (3, 'Linda', 'Douglas');
INSERT IGNORE INTO vets VALUES (4, 'Rafael', 'Ortega');
INSERT IGNORE INTO vets VALUES (5, 'Henry', 'Stevens');
INSERT IGNORE INTO vets VALUES (6, 'Sharon', 'Jenkins');
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 vet_specialties VALUES (2, 1);
INSERT IGNORE INTO vet_specialties VALUES (3, 2);
INSERT IGNORE INTO vet_specialties VALUES (3, 3);
INSERT IGNORE INTO vet_specialties VALUES (4, 2);
INSERT IGNORE INTO vet_specialties VALUES (5, 1);
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 types VALUES (1, 'cat');
INSERT IGNORE INTO types VALUES (2, 'dog');
INSERT IGNORE INTO types VALUES (3, 'lizard');
INSERT IGNORE INTO types VALUES (4, 'snake');
INSERT IGNORE INTO types VALUES (5, 'bird');
INSERT IGNORE INTO types VALUES (6, 'hamster');
INSERT IGNORE INTO gender VALUES (1, 'male');
INSERT IGNORE INTO gender VALUES (2, 'female');
INSERT IGNORE INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
INSERT IGNORE INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
INSERT IGNORE INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
INSERT IGNORE INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
INSERT IGNORE INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
INSERT IGNORE INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
INSERT IGNORE INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
INSERT IGNORE INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
INSERT IGNORE INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT IGNORE INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
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 pets VALUES (1, 'Leo', '2000-09-07', 1, 1);
INSERT IGNORE INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);
INSERT IGNORE INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3);
INSERT IGNORE INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3);
INSERT IGNORE INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4);
INSERT IGNORE INTO pets VALUES (6, 'George', '2000-01-20', 4, 5);
INSERT IGNORE INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6);
INSERT IGNORE INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6);
INSERT IGNORE INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7);
INSERT IGNORE INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8);
INSERT IGNORE INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9);
INSERT IGNORE INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10);
INSERT IGNORE INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10);
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');

View file

@ -1,14 +1,14 @@
CREATE DATABASE IF NOT EXISTS petclinic;
CREATE DATABASE IF NOT EXISTS kidclinic;
ALTER DATABASE petclinic
ALTER DATABASE kidclinic
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc';
GRANT ALL PRIVILEGES ON kidclinic.* TO pc@localhost IDENTIFIED BY 'pc';
USE petclinic;
USE kidclinic;
CREATE TABLE IF NOT EXISTS vets (
CREATE TABLE IF NOT EXISTS doctors (
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30),
@ -21,21 +21,21 @@ CREATE TABLE IF NOT EXISTS specialties (
INDEX(name)
) engine=InnoDB;
CREATE TABLE IF NOT EXISTS vet_specialties (
vet_id INT(4) UNSIGNED NOT NULL,
CREATE TABLE IF NOT EXISTS doctor_specialties (
doctor_id INT(4) UNSIGNED NOT NULL,
specialty_id INT(4) UNSIGNED NOT NULL,
FOREIGN KEY (vet_id) REFERENCES vets(id),
FOREIGN KEY (doctor_id) REFERENCES doctors(id),
FOREIGN KEY (specialty_id) REFERENCES specialties(id),
UNIQUE (vet_id,specialty_id)
UNIQUE (doctor_id,specialty_id)
) engine=InnoDB;
CREATE TABLE IF NOT EXISTS types (
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 owners (
CREATE TABLE IF NOT EXISTS parents (
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30),
@ -45,21 +45,21 @@ CREATE TABLE IF NOT EXISTS owners (
INDEX(last_name)
) engine=InnoDB;
CREATE TABLE IF NOT EXISTS pets (
CREATE TABLE IF NOT EXISTS kids (
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30),
birth_date DATE,
type_id INT(4) UNSIGNED NOT NULL,
owner_id INT(4) UNSIGNED NOT NULL,
gender_id INT(4) UNSIGNED NOT NULL,
parent_id INT(4) UNSIGNED NOT NULL,
INDEX(name),
FOREIGN KEY (owner_id) REFERENCES owners(id),
FOREIGN KEY (type_id) REFERENCES types(id)
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,
pet_id INT(4) UNSIGNED NOT NULL,
kid_id INT(4) UNSIGNED NOT NULL,
visit_date DATE,
description VARCHAR(255),
FOREIGN KEY (pet_id) REFERENCES pets(id)
FOREIGN KEY (kid_id) REFERENCES kids(id)
) engine=InnoDB;

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'doctors')}">
<body>
<h2>Pediatricians</h2>
<table id="doctors" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Specialties</th>
</tr>
</thead>
<tbody>
<tr th:each="doctor : ${doctors.doctorList}">
<td th:text="${doctor.firstName + ' ' + doctor.lastName}"></td>
<td th:text="${doctor.address}"></td>
<td th:text="${doctor.city}"></td>
<td th:text="${doctor.state}"></td>
<td><span th:each="specialty : ${doctor.specialties}"
th:text="${specialty.name + ' '}" /> <span
th:if="${doctor.nrOfSpecialties == 0}">none</span></td>
</tr>
</tbody>
</table>
<p>This is a test let me know if this works.</p>
</body>
<footer> </footer>
</html>

View file

@ -3,8 +3,7 @@
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">
<body>
<img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
<h2>Something happened...</h2>
<h2>Errors</h2>
<p th:text="${message}">Exception message</p>
</body>

View file

@ -3,14 +3,14 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1"> -->
<link rel="shortcut icon" type="image/x-icon" th:href="@{/resources/images/favicon.png}">
<title>PetClinic :: a Spring Framework demonstration</title>
<title>KidClinic :: a Spring Framework demonstration</title>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
@ -22,24 +22,45 @@
</head>
<body>
<h5>
<nav class="navbar navbar-inverse navbar-fixed-top navbar-right" role="navigation" th:fragment="header">
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" th:href="@{/}"><span></span></a>
<!-- <a class="navbar-brand" th:href="@{/}"><span></span></a> -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
<span class="sr-only"><os-p>Toggle navigation</os-p></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="main-navbar">
<ul class="nav navbar-nav navbar-right">
<li th:fragment="menuItem (path,active,title,glyph,text)" class="active" th:class="${active==menu ? 'active' : ''}">
<ul class="nav navbar-nav nav-collapse navbar-right">
<a class="navbar-brand" href="#" size="5">KidClinic</a>
<li th:class="${module == 'home' ? 'active' : ''}"><a href="#" th:href="@{/}" ><span class="glyphicon glyphicon-home"> Home</a></li>
<li th:classappend="${module == 'parents' ? 'active' : ''}"><a href="/parents/find" th:href="@{/parents/find}" ><span class="glyphicon glyphicon-search"> Parents</a></li>
<li th:classappend="${module == 'doctors' ? 'active' : ''}"><a href="/doctors.html" th:href="@{/doctors.html}"><span class="glyphicon glyphicon-th-list"> Doctors</a></li>
<li th:classappend="${module == 'reviews' ? 'active' : ''}"><a href="/reviews.html" th:href="@{/reviews.html}"><span class="glyphicon glyphicon-star"> Reviews</a></li>
<li th:classappend="${module == 'error' ? 'active' : ''}"><a href="/oops" th:href="@{/oops}" ><span class="glyphicon glyphicon-warning-sign"> Errors</a></li>
<li th:classappend="${module == 'map' ? 'active' : ''}"><a href="/map.html" th:href= "@{/map.html}"><span class = "glyphicon glyphicon-map-marker " > Map</a></li>
<!-- <li th:fragment="menuItem (path,active,title,glyph,text)" th:class="${active==menu ? 'active' : ''}">
<a th:href="@{__${path}__}" th:title="${title}">
<span th:class="'glyphicon glyphicon-'+${glyph}" class="glyphicon glyphicon-home" aria-hidden="true"></span>
<span th:class="'glyphicon glyphicon-'+${glyph}" class="glyphicon glyphicon-home" aria-hidden="false"></span>
<span th:text="${text}">Template</span>
</a>
</li>
@ -49,41 +70,35 @@
<span>Home</span>
</li>
<li th:replace="::menuItem ('/owners/find','owners','find owners','search','Find owners')">
<li th:replace="::menuItem ('/owners/find','owners','Find Parents','search','Find Parents')">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
<span>Find owners</span>
<span>Find Parents</span>
</li>
<li th:replace="::menuItem ('/vets.html','vets','veterinarians','th-list','Veterinarians')">
<li th:replace="::menuItem ('/vets.html','vets', 'Pediatricians','th-list','Pediatricians')">
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
<span>Veterinarians</span>
<span>Pediatricians</span>
</li>
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Error')">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
<span>Error</span>
</li>
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Reviews')">
<span class=" glyphicon glyphicon-star-empty" aria-hidden="true"></span>
<span>Reviews</span>
</li> -->
</ul>
</div>
</div>
</nav>
</h5>
<div class="container-fluid">
<div class="container xd-container">
<div th:replace="${template}"/>
<br/>
<br/>
<div class="container">
<div class="row">
<div class="col-12 text-center">
<img src="../static/resources/images/spring-pivotal-logo.png" th:src="@{/resources/images/spring-pivotal-logo.png}"
alt="Sponsored by Pivotal"/></div>
</div>
</div>
</div>
</div>
<script th:src="@{/webjars/jquery/jquery.min.js}"></script>
<script th:src="@{/webjars/jquery-ui/jquery-ui.min.js}"></script>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'map')}">
<body>
<h2>Map</h2>
<p>We are currently curating our Map.</p>
</body>
</html>

View file

@ -0,0 +1,43 @@
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'parents')}">
<body>
<h2>
<th:block th:if="${kid['new']}">New </th:block>
Kid
</h2>
<form th:object="${kid}" class="form-horizontal" method="post">
<input type="hidden" name="id" th:value="*{id}" />
<div class="form-group has-feedback">
<div class="form-group">
<label class="col-sm-2 control-label">Parent</label>
<div class="col-sm-10">
<span th:text="${kid.parent?.firstName + ' ' + kid.parent?.lastName}" />
</div>
</div>
<input
th:replace="~{fragments/inputField :: input ('Name', 'name')}" />
<input
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate')}" />
<input
th:replace="~{fragments/selectField :: select ('Gender', 'gender', ${gender})}" />
<input
th:replace="~{fragments/inputField :: input ('Allergies', 'allergies')}" />
<input
th:replace="~{fragments/inputField :: input ('Medications', 'medications')}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button
th:with="text=${parent['new']} ? 'Add Kid' : 'Update Kid'"
class="btn btn-default" type="submit" th:text="${text}">Add
Kid</button>
</div>
</div>
</form>
</body>
</html>

View file

@ -1,5 +1,5 @@
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
th:replace="~{fragments/layout :: layout (~{::body},'parents')}">
<body>
@ -8,23 +8,23 @@
Visit
</h2>
<b>Pet</b>
<b>Kid</b>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Birth Date</th>
<th>Type</th>
<th>Owner</th>
<th>Parent</th>
</tr>
</thead>
<tr>
<td th:text="${pet.name}" /></td>
<td th:text="${kid.name}" /></td>
<td
th:text="${#calendars.format(pet.birthDate, 'yyyy-MM-dd')}" /></td>
<td th:text="${pet.type}" /></td>
th:text="${#calendars.format(kid.birthDate, 'yyyy-MM-dd')}" /></td>
<td th:text="${kid.gender}" /></td>
<td
th:text="${pet.owner?.firstName + ' ' + pet.owner?.lastName}" /></td>
th:text="${kid.parent?.firstName + ' ' + kid.parent?.lastName}" /></td>
</tr>
</table>
@ -38,7 +38,7 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="petId" th:value="${pet.id}" />
<input type="hidden" name="kidId" th:value="${kid.id}" />
<button class="btn btn-default" type="submit">Add Visit</button>
</div>
</div>
@ -51,7 +51,7 @@
<th>Date</th>
<th>Description</th>
</tr>
<tr th:if="${!visit['new']}" th:each="visit : ${pet.visits}">
<tr th:if="${!visit['new']}" th:each="visit : ${kid.visits}">
<td th:text="${#calendars.format(visit.date, 'yyyy-MM-dd')}" /></td>
<td th:text=" ${visit.description}" /></td>
</tr>

View file

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'doctors')}">
<body>
<h2>Map</h2>
<p>We are currently curating our Map</p>
<table id="doctors" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Specialties</th>
</tr>
</thead>
<tbody>
<tr th:each="doctor : ${doctors.doctorList}">
<td th:text="${doctor.firstName + ' ' + doctor.lastName}"></td>
<td th:text="${doctor.address}"></td>
<td th:text="${doctor.city}"></td>
<td th:text="${doctor.state}"></td>
<td><span th:each="specialty : ${doctor.specialties}"
th:text="${specialty.name + ' '}" /> <span
th:if="${doctor.nrOfSpecialties == 0}">none</span></td>
</tr>
</tbody>
</table>
<button onclick="displayAddresses()">Click me</button>
<script type="text/javascript" th:inline="javascript">
function displayAddresses()
{
var dlist = /*[[${doctors.doctorList}]]*/;
var d = "";
for (i = 0; i < dlist.length; i++)
{
d = dlist[i];
console.log(d);
}
}
</script>
</body>
</html>

View file

@ -0,0 +1,106 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'map')}">
<body>
<h2 style="background-color: white; position: centered;">Map</h2>
<div class="form-group">
<label for="usr">Your Address</label>
<input type="text" class="form-control" id="usr">
</div>
<div class="btn-group btn-group-justified">
<a onclick ="displayAddresses()" class="btn btn-primary">See Doctors</a>
<a onclick="displayPatient()" class="btn btn-primary">See Your Address</a>
</div>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAfrxRUJL-3gcMNhoiOeu85oB69PkbvgMc&callback=initial">
</script>
<script type="text/javascript" th:inline="javascript" >
var map;
var geocoder;
function initial() {
geocoder= new google.maps.Geocoder();
var latlng = new google.maps.LatLng(43.0731, -89.4012);
var mapOptions = {
zoom: 8,
center: latlng
}
map = new google.maps.Map(document.getElementById('map'), mapOptions);
}
function displayAddresses()
{
var dlist = /*[[${doctors.doctorList}]]*/;
var d = "";
for (i = 0; i < dlist.length; i++)
{
d = dlist[i].address.concat(", ").concat(dlist[i].city).concat(", ").concat(dlist[i].state);
console.log(d);
geocoder.geocode( { 'address': d}, function(results, status) {
var marker = new google.maps.Marker({
map: map, position: results[0].geometry.location});
});
}
}
function displayPatient()
{
var alpha = document.getElementById('usr').value;
geocoder.geocode( { 'address': alpha}, function(results, status) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map, icon: "/resources/images/blue_MarkerA.png", position: results[0].geometry.location});
});
}
</script>
<div id="map" ></div>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</body>
</html>

View file

@ -1,83 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body>
<h2>Owner Information</h2>
<table class="table table-striped" th:object="${owner}">
<tr>
<th>Name</th>
<td><b th:text="*{firstName + ' ' + lastName}"></b></td>
</tr>
<tr>
<th>Address</th>
<td th:text="*{address}" /></td>
</tr>
<tr>
<th>City</th>
<td th:text="*{city}" /></td>
</tr>
<tr>
<th>Telephone</th>
<td th:text="*{telephone}" /></td>
</tr>
</table>
<a th:href="@{{id}/edit(id=${owner.id})}" class="btn btn-default">Edit
Owner</a>
<a th:href="@{{id}/pets/new(id=${owner.id})}" class="btn btn-default">Add
New Pet</a>
<br />
<br />
<br />
<h2>Pets and Visits</h2>
<table class="table table-striped">
<tr th:each="pet : ${owner.pets}">
<td valign="top">
<dl class="dl-horizontal">
<dt>Name</dt>
<dd th:text="${pet.name}" /></dd>
<dt>Birth Date</dt>
<dd
th:text="${#calendars.format(pet.birthDate, 'yyyy-MM-dd')}" /></dd>
<dt>Type</dt>
<dd th:text="${pet.type}" /></dd>
</dl>
</td>
<td valign="top">
<table class="table-condensed">
<thead>
<tr>
<th>Visit Date</th>
<th>Description</th>
</tr>
</thead>
<tr th:each="visit : ${pet.visits}">
<td th:text="${#calendars.format(visit.date, 'yyyy-MM-dd')}"></td>
<td th:text="${visit?.description}"></td>
</tr>
<tr>
<td><a
th:href="@{{ownerId}/pets/{petId}/edit(ownerId=${owner.id},petId=${pet.id})}">Edit
Pet</a></td>
<td><a
th:href="@{{ownerId}/pets/{petId}/visits/new(ownerId=${owner.id},petId=${pet.id})}">Add
Visit</a></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

View file

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body>
<h2>Owners</h2>
<table id="vets" class="table table-striped">
<thead>
<tr>
<th style="width: 150px;">Name</th>
<th style="width: 200px;">Address</th>
<th>City</th>
<th style="width: 120px">Telephone</th>
<th>Pets</th>
</tr>
</thead>
<tbody>
<tr th:each="owner : ${selections}">
<td>
<a th:href="@{owners/__${owner.id}__}" th:text="${owner.firstName + ' ' + owner.lastName}"/></a>
</td>
<td th:text="${owner.address}"/>
<td th:text="${owner.city}"/>
<td th:text="${owner.telephone}"/>
<td><span th:each="pet : ${owner.pets}" th:text="${pet.name} "/></td>
</tr>
</tbody>
</table>
</body>
</html>

View file

@ -1,10 +1,10 @@
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
th:replace="~{fragments/layout :: layout (~{::body},'parents')}">
<body>
<h2>Owner</h2>
<form th:object="${owner}" class="form-horizontal" id="add-owner-form" method="post">
<h2>Parent</h2>
<form th:object="${parent}" class="form-horizontal" id="add-parent-form" method="post">
<div class="form-group has-feedback">
<input
th:replace="~{fragments/inputField :: input ('First Name', 'firstName')}" />
@ -14,15 +14,17 @@
th:replace="~{fragments/inputField :: input ('Address', 'address')}" />
<input
th:replace="~{fragments/inputField :: input ('City', 'city')}" />
<input
th:replace="~{fragments/inputField :: input ('State', 'state')}" />
<input
th:replace="~{fragments/inputField :: input ('Telephone', 'telephone')}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button
th:with="text=${owner['new']} ? 'Add Owner' : 'Update Owner'"
th:with="text=${parent['new']} ? 'Add Parent' : 'Update Parent'"
class="btn btn-default" type="submit" th:text="${text}">Add
Owner</button>
Parent</button>
</div>
</div>
</form>

View file

@ -1,12 +1,12 @@
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
th:replace="~{fragments/layout :: layout (~{::body},'parents')}">
<body>
<h2>Find Owners</h2>
<h2>Find Parents</h2>
<form th:object="${owner}" th:action="@{/owners}" method="get"
class="form-horizontal" id="search-owner-form">
<form th:object="${parent}" th:action="@{/parents}" method="get"
class="form-horizontal" id="search-parent-form">
<div class="form-group">
<div class="control-group" id="lastName">
<label class="col-sm-2 control-label">Last name </label>
@ -22,14 +22,14 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Find
Owner</button>
Parent</button>
</div>
</div>
</form>
<br />
<a class="btn btn-default" th:href="@{/owners/new}">Add Owner</a>
<a class="btn btn-default" th:href="@{/parents/new}">Add Parent</a>
</body>
</html>

View file

@ -0,0 +1,210 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'parents')}" >
<body onload="codeAddress()">
<h2>Parent Information</h2>
<table class="table table-striped" th:object="${parent}">
<tr>
<th>Name</th>
<td><b th:text="*{firstName + ' ' + lastName}"></b></td>
</tr>
<tr>
<th>Address</th>
<td th:text="*{address}" /></td>
</tr>
<tr>
<th>City</th>
<td th:text="*{city}" /></td>
</tr>
<tr>
<th>State</th>
<td th:text="*{state}" /></td>
</tr>
<tr>
<th>Telephone</th>
<td th:text="*{telephone}" /></td>
</tr>
</table>
<a th:href="@{{id}/edit(id=${parent.id})}" class="btn btn-default">Edit
Parent</a>
<a th:href="@{{id}/kids/new(id=${parent.id})}" class="btn btn-default">Add
New Child</a>
<br />
<br />
<br />
<h2>Children and Visits</h2>
<table class="table table-striped">
<tr th:each="kid : ${parent.kids}">
<td valign="top">
<dl class="dl-horizontal">
<dt>Name</dt>
<dd th:text="${kid.name}" /></dd>
<dt>Birth Date</dt>
<dd
th:text="${#calendars.format(kid.birthDate, 'yyyy-MM-dd')}" /></dd>
<dt>Gender</dt>
<dd th:text="${kid.gender}" /></dd>
<dt>Allergies</dt>
<dd th:text="${kid.allergies}" /></dd>
<dt>Medications</dt>
<dd th:text="${kid.medications}" /></dd>
</dl>
</td>
<td valign="top">
<table class="table-condensed">
<thead>
<tr>
<th>Visit Date</th>
<th>Description</th>
</tr>
</thead>
<tr th:each="visit : ${kid.visits}">
<td th:text="${#calendars.format(visit.date, 'yyyy-MM-dd')}"></td>
<td th:text="${visit?.description}"></td>
</tr>
<tr>
<td><a
th:href="@{{parentId}/kids/{kidId}/edit(parentId=${parent.id},kidId=${kid.id})}">Edit
Child</a></td>
<td><a
th:href="@{{parentId}/kids/{kidId}/visits/new(parentId=${parent.id},kidId=${kid.id})}">Add
Visit</a></td>
</tr>
</table>
</td>
</tr>
</table>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDHmKh1g1i4_M15YR95GlCZK7cQWe87lIQ&callback=initialize">
</script>
<script th:inline="javascript">
// Note: This example requires that you consent to location sharing when
// prompted by your browser. If you see the error "The Geolocation service
// failed.", it means you probably did not give permission for the browser to
// locate you.
//var map, infoWindow;
// console.log(/*[[${parent.address}]]*/);
// function initialize() {
// getCoordinates(/*[[${parent.address}]]*/, function(coords) {
// var mapOptions = {
// zoom: 12,
// center: new google.maps.LatLng(coords[0],coords[1]),
// mapTypeId: google.maps.mapTypeId.ROADMAP
// };
// map = new google.maps.Map(document.getElementById('map'), mapOptions);
// })
// }
// google.maps.event.addDomListener(window, 'load', initialize);
/*function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 6
});
infoWindow = new google.maps.InfoWindow;*/
// Try HTML5 geolocation.
/*if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition(pos);
infoWindow.setContent('Location found.');
infoWindow.open(map);
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}*/
// function handleLocationError(browserHasGeolocation, infoWindow, pos) {
// infoWindow.setPosition(pos);
// infoWindow.setContent(browserHasGeolocation ?
// 'Error: The Geolocation service failed.' :
// 'Error: Your browser doesn\'t support geolocation.');
// infoWindow.open(map);
// }
////////////////////////////////////////////////////////////////////////////////////
</script>
<!-- <p th:text="${doctors.doctorList}" /> -->
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</body>
</html>

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'parents')}">
<body>
<h2>Parents</h2>
<table id="doctors" class="table table-striped">
<thead>
<tr>
<th style="width: 150px;">Name</th>
<th style="width: 200px;">Address</th>
<th style="width: 150px;">City</th>
<th style="width: 150px;">State</th>
<th style="width: 120px;">Telephone</th>
<th style="width: 150px;">Children</th>
</tr>
</thead>
<tbody>
<tr th:each="parent : ${selections}">
<td>
<a th:href="@{parents/__${parent.id}__}" th:text="${parent.firstName + ' ' + parent.lastName}"/></a>
</td>
<td th:text="${parent.address}"/>
<td th:text="${parent.city}"/>
<td th:text="${parent.state}"/>
<td th:text="${parent.telephone}"/>
<td><span th:each="kid : ${parent.kids}" th:text="${kid.name} + ' '"/></td>
</tr>
</tbody>
</table>
</body>
</html>

View file

@ -1,38 +0,0 @@
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body>
<h2>
<th:block th:if="${pet['new']}">New </th:block>
Pet
</h2>
<form th:object="${pet}" class="form-horizontal" method="post">
<input type="hidden" name="id" th:value="*{id}" />
<div class="form-group has-feedback">
<div class="form-group">
<label class="col-sm-2 control-label">Owner</label>
<div class="col-sm-10">
<span th:text="${pet.owner?.firstName + ' ' + pet.owner?.lastName}" />
</div>
</div>
<input
th:replace="~{fragments/inputField :: input ('Name', 'name')}" />
<input
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate')}" />
<input
th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button
th:with="text=${owner['new']} ? 'Add Pet' : 'Update Pet'"
class="btn btn-default" type="submit" th:text="${text}">Add
Pet</button>
</div>
</div>
</form>
</body>
</html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'reviews')}">
<body>
<h2>Reviews</h2>
<p>We are currently curating our review.</p>
</body>
</html>

View file

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'vets')}">
<body>
<h2>Veterinarians</h2>
<table id="vets" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Specialties</th>
</tr>
</thead>
<tbody>
<tr th:each="vet : ${vets.vetList}">
<td th:text="${vet.firstName + ' ' + vet.lastName}"></td>
<td><span th:each="specialty : ${vet.specialties}"
th:text="${specialty.name + ' '}" /> <span
th:if="${vet.nrOfSpecialties == 0}">none</span></td>
</tr>
</tbody>
</table>
<table class="table-buttons">
<tr>
<td><a th:href="@{/vets.xml}">View as XML</a></td>
<td><a th:href="@{/vets.json}">View as JSON</a></td>
</tr>
</table>
</body>
</html>

View file

@ -1,16 +1,106 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'home')}">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<div id ="navbar-2" class="container-custom">
<body>
<ul class="nav navbar-nav nav-collapse navbar-right">
<li > <a href="#myCarousel" class="active">Photos</a> </li>
<li > <a href="#portion2">About</a> </li>
<li > <a href="#portion3">Features</a></li>
<li > <a href="#portion4">Future</a></li>
</ul>
</div>
<h2 th:text="#{welcome}">Welcome</h2>
<div class="row">
<div class="col-md-12">
<img class="img-responsive" src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
<!-- This is a test for a picture car. -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="../static/resources/images/doctor4.jpg" th:src="@{/resources/images/doctor4.jpg}" alt="Doctor" style="width:100%;">
</div>
<div class="item">
<img src="../static/resources/images/doctor5.jpg" th:src="@{/resources/images/doctor5.jpg}" alt="Doctor" style="width:100%;">
</div>
<div class="item">
<img src="../static/resources/images/doctor3.jpg" th:src="@{/resources/images/doctor3.jpg}" alt="Doctor" style="width:100%;">
</div>
</div>
</body>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div id= "portion2" class="portion two">
<h2>Our Story</h2>
</div>
<div class="info">
<h3>Creation</h3>
<p>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.</p>
</div>
<div class="portion five" id ="portion3">
<h2>Features</h2>
</div>
<div class="info">
<h3>Parents</h3>
<p>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.
</p>
<h3>Doctors</h3>
<p>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.
</p>
<h3>Reviews</h3>
<p>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.
</p>
</div>
<div class="portion four" id="portion4">
<h2>The Future</h2>
</div>
<div class="info">
<h3>Our Vision</h3>
<p>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.
</p>
<br />
<br />
<div class="button">
<a href="#">To Top</a>
</div>
</div>
</body>
</html>

View file

@ -1,45 +0,0 @@
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<ConstraintViolation<Person>> constraintViolations = validator.validate(person);
assertThat(constraintViolations.size()).isEqualTo(1);
ConstraintViolation<Person> violation = constraintViolations.iterator().next();
assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName");
assertThat(violation.getMessage()).isEqualTo("may not be empty");
}
}

View file

@ -1,179 +0,0 @@
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"));
}
}

View file

@ -1,127 +0,0 @@
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"));
}
}

View file

@ -1,80 +0,0 @@
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<PetType> makePetTypes() {
List<PetType> petTypes = new ArrayList<>();
petTypes.add(new PetType(){
{
setName("Dog");
}
});
petTypes.add(new PetType(){
{
setName("Bird");
}
});
return petTypes;
}
}

View file

@ -1,75 +0,0 @@
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"));
}
}

View file

@ -1,206 +0,0 @@
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.
* <p>
* ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided by the Spring
* TestContext Framework: </p> <ul> <li><strong>Spring IoC container caching</strong> which spares us unnecessary set up
* time between test execution.</li> <li><strong>Dependency Injection</strong> of test fixture instances, meaning that
* we don't need to perform application context lookups. See the use of {@link Autowired @Autowired} on the <code>{@link
* ClinicServiceTests#clinicService clinicService}</code> instance variable, which uses autowiring <em>by
* type</em>. <li><strong>Transaction management</strong>, 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. <li> An {@link org.springframework.context.ApplicationContext
* ApplicationContext} is also inherited and can be used for explicit bean lookup if necessary. </li> </ul>
*
* @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<Owner> 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<Owner> 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<PetType> 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<PetType> 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<Vet> 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<Visit> 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);
}
}

View file

@ -1,54 +0,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.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 extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
throws ObjectRetrievalFailureException {
for (T entity : entities) {
if (entity.getId() == entityId && entityClass.isInstance(entity)) {
return entity;
}
}
throw new ObjectRetrievalFailureException(entityClass, entityId);
}
}

View file

@ -1,38 +0,0 @@
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());
}
}

View file

@ -1,23 +0,0 @@
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
}
}

View file

@ -1,82 +0,0 @@
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")));
}
}

View file

@ -1,43 +0,0 @@
/*
* 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());
}
}

View file

@ -1,411 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13 r1665067">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="PETCLINIC_HOST" elementType="Argument">
<stringProp name="Argument.name">PETCLINIC_HOST</stringProp>
<stringProp name="Argument.value">localhost</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="PETCLINIC_PORT" elementType="Argument">
<stringProp name="Argument.name">PETCLINIC_PORT</stringProp>
<stringProp name="Argument.value">8080</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="CONTEXT_WEB" elementType="Argument">
<stringProp name="Argument.name">CONTEXT_WEB</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="User threads" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Contr<74>leur Boucle" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">10</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">500</stringProp>
<stringProp name="ThreadGroup.ramp_time">10</stringProp>
<longProp name="ThreadGroup.start_time">1361531541000</longProp>
<longProp name="ThreadGroup.end_time">1361531541000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.delayedStart">true</boolProp>
<stringProp name="TestPlan.comments">Original : 500 - 10 - 10</stringProp>
</ThreadGroup>
<hashTree>
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Fixed time counter" enabled="true">
<stringProp name="ConstantTimer.delay">300</stringProp>
</ConstantTimer>
<hashTree/>
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="Default HTTP parameters" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">${PETCLINIC_HOST}</stringProp>
<stringProp name="HTTPSampler.port">${PETCLINIC_PORT}</stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.concurrentPool">4</stringProp>
</ConfigTestElement>
<hashTree/>
<CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP cookie manager" enabled="true">
<collectionProp name="CookieManager.cookies"/>
<boolProp name="CookieManager.clearEachIteration">true</boolProp>
</CookieManager>
<hashTree/>
<CounterConfig guiclass="CounterConfigGui" testclass="CounterConfig" testname="User Count" enabled="true">
<stringProp name="CounterConfig.start">1</stringProp>
<stringProp name="CounterConfig.end">10</stringProp>
<stringProp name="CounterConfig.incr">1</stringProp>
<stringProp name="CounterConfig.name">count</stringProp>
<stringProp name="CounterConfig.format"></stringProp>
<boolProp name="CounterConfig.per_user">false</boolProp>
</CounterConfig>
<hashTree/>
<CounterConfig guiclass="CounterConfigGui" testclass="CounterConfig" testname="Pet Count" enabled="true">
<stringProp name="CounterConfig.start">1</stringProp>
<stringProp name="CounterConfig.end">13</stringProp>
<stringProp name="CounterConfig.incr">1</stringProp>
<stringProp name="CounterConfig.name">petCount</stringProp>
<stringProp name="CounterConfig.format"></stringProp>
<boolProp name="CounterConfig.per_user">false</boolProp>
</CounterConfig>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Home page" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="CSS" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/resources/css/petclinic.css</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="JS" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/vendors/jquery/jquery.js</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Vets" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/vets.html</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Find owner" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/find.html</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Find owner with lastname=&quot;&quot;" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners.html?lastName=</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Owner" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/${count}.html</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Edit Owner" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/${count}/edit.html</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="POST Edit Owner" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">firstName=Test&amp;lastName=${count}&amp;address=1234+Test+St.&amp;city=TestCity&amp;telephone=612345678</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/${count}/edit.html</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="New visit" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="POST new visit" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">date=2013%2F02%2F22&amp;description=visit</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/${count}/pets/${petCount}/visits/new</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Owner" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pr<70>-d<>finies" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${CONTEXT_WEB}/owners/${count}.html</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Results" enabled="false">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="Aggregated report" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>

1
update.sh Executable file
View file

@ -0,0 +1 @@
./kill.sh && git pull origin sasank && ./run.sh &