Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • s51119/broken-petclinic
  • s72462/broken-petclinic
  • s61200/broken-petclinic
  • s76620/broken-petclinic
  • s76545/broken-petclinic
  • s76915/broken-petclinic
  • s70130/broken-petclinic
  • s72523/broken-petclinic
  • s77047/broken-petclinic
  • s70178/broken-petclinic
  • s76522/broken-petclinic
  • s76426/broken-petclinic
  • s76863/broken-petclinic
  • s76856/broken-petclinic
  • s76728/broken-petclinic
  • williamreetz/broken-petclinic
  • s77034/broken-petclinic
  • s76400/broken-petclinic
  • s72288/broken-petclinic
  • s76608/broken-petclinic
20 results
Show changes
Showing
with 545 additions and 484 deletions
package org.springframework.samples.petclinic.web;
import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.Owner;
import org.springframework.samples.petclinic.Pet;
import org.springframework.samples.petclinic.PetType;
import org.springframework.samples.petclinic.service.ClinicService;
import org.springframework.samples.petclinic.validation.PetValidator;
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.ModelAttribute;
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.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;
/**
* JavaBean form controller that is used to add a new <code>Pet</code> to the
* system.
*
* @author Juergen Hoeller
* @author Ken Krebs
* @author Arjen Poutsma
*/
@Controller
@SessionAttributes("pet")
public class PetController {
private final ClinicService clinicService;
@Autowired
public PetController(ClinicService clinicService) {
this.clinicService = clinicService;
}
@ModelAttribute("types")
public Collection<PetType> populatePetTypes() {
return this.clinicService.findPetTypes();
}
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
@RequestMapping(value="/owners/{ownerId}/pets/new", method = RequestMethod.GET)
public String initCreationForm(@PathVariable("ownerId") int ownerId, Model model) {
Owner owner = this.clinicService.findOwnerById(ownerId);
Pet pet = new Pet();
owner.addPet(pet);
model.addAttribute("pet", pet);
return "pets/createOrUpdatePetForm";
}
@RequestMapping(value="/owners/{ownerId}/pets/new", method = RequestMethod.POST)
public String processCreationForm(@ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) {
new PetValidator().validate(pet, result);
if (result.hasErrors()) {
return "pets/createOrUpdatePetForm";
}
else {
this.clinicService.savePet(pet);
status.setComplete();
return "redirect:/owners/" + pet.getOwner().getId();
}
}
@RequestMapping(value="/owners/*/pets/{petId}/edit", method = RequestMethod.GET)
public String initUpdateForm(@PathVariable("petId") int petId, Model model) {
Pet pet = this.clinicService.findPetById(petId);
model.addAttribute("pet", pet);
return "pets/createOrUpdatePetForm";
}
@RequestMapping(value="/owners/*/pets/{petId}/edit", method = { RequestMethod.PUT, RequestMethod.POST })
public String processUpdateForm(@ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) {
// we're not using @Valid annotation here because it is easier to define such validation rule in Java
new PetValidator().validate(pet, result);
if (result.hasErrors()) {
return "pets/createOrUpdatePetForm";
}
else {
this.clinicService.savePet(pet);
status.setComplete();
return "redirect:/owners/" + pet.getOwner().getId();
}
}
}
package org.springframework.samples.petclinic.web;
import java.text.ParseException;
import java.util.Collection;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.Formatter;
import org.springframework.samples.petclinic.PetType;
import org.springframework.samples.petclinic.service.ClinicService;
/**
* @author Mark Fisher
* @author Juergen Hoeller
* @author Michael Isvy
*/
public class PetTypeFormatter implements Formatter<PetType> {
private final ClinicService clinicService;
@Autowired
public PetTypeFormatter(ClinicService clinicService) {
this.clinicService = clinicService;
}
@Override
public String print(PetType petType, Locale locale) {
return petType.getName();
}
@Override
public PetType parse(String text, Locale locale) throws ParseException {
Collection<PetType> findPetTypes = this.clinicService.findPetTypes();
for (PetType type : findPetTypes) {
if (type.getName().equals(text)) {
return type;
}
}
throw new ParseException("type not found: "+text, 0);
}
}
package org.springframework.samples.petclinic.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.Vets;
import org.springframework.samples.petclinic.service.ClinicService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Annotation-driven <em>MultiActionController</em> that handles all non-form
* URL's.
*
* @author Juergen Hoeller
* @author Mark Fisher
* @author Ken Krebs
* @author Arjen Poutsma
*/
@Controller
public class VetController {
private final ClinicService clinicService;
@Autowired
public VetController(ClinicService clinicService) {
this.clinicService = clinicService;
}
/**
* Custom handler for displaying vets.
*
* <p>Note that this handler returns a plain {@link ModelMap} object instead of
* a ModelAndView, thus leveraging convention-based model attribute names.
* It relies on the RequestToViewNameTranslator to determine the logical
* view name based on the request URL: "/vets.do" -&gt; "vets".
*
* @return a ModelMap with the model attributes for the view
*/
@RequestMapping("/vets")
public String showVetList(Model model) {
Vets vets = new Vets();
vets.getVetList().addAll(this.clinicService.findVets());
model.addAttribute("vets", vets);
return "vets/vetList";
}
}
package org.springframework.samples.petclinic.web;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.Pet;
import org.springframework.samples.petclinic.Visit;
import org.springframework.samples.petclinic.service.ClinicService;
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.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.servlet.ModelAndView;
/**
* JavaBean form controller that is used to add a new <code>Visit</code> to the
* system.
*
* @author Juergen Hoeller
* @author Ken Krebs
* @author Arjen Poutsma
*/
@Controller
@SessionAttributes("visit")
public class VisitController {
private final ClinicService clinicService;
@Autowired
public VisitController(ClinicService clinicService) {
this.clinicService = clinicService;
}
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
@RequestMapping(value="/owners/*/pets/{petId}/visits/new", method = RequestMethod.GET)
public String initNewVisitForm(@PathVariable("petId") int petId, Model model) {
Pet pet = this.clinicService.findPetById(petId);
Visit visit = new Visit();
pet.addVisit(visit);
model.addAttribute("visit", visit);
return "pets/createOrUpdateVisitForm";
}
@RequestMapping(value="/owners/*/pets/{petId}/visits/new", method = RequestMethod.POST)
public String processNewVisitForm(@Valid Visit visit, BindingResult result, SessionStatus status) {
if (result.hasErrors()) {
return "pets/createOrUpdateVisitForm";
}
else {
this.clinicService.saveVisit(visit);
status.setComplete();
return "redirect:/owners/" + visit.getPet().getOwner().getId();
}
}
/**
* Custom handler for displaying an list of visits.
*
* @param petId the ID of the pet whose visits to display
* @return a ModelMap with the model attributes for the view
*/
@RequestMapping(value="/owners/*/pets/{petId}/visits", method=RequestMethod.GET)
public ModelAndView showVisits(@PathVariable int petId) {
ModelAndView mav = new ModelAndView("visitList");
mav.addObject("visits", this.clinicService.findPetById(petId).getVisits());
return mav;
}
}
/*
* Copyright 2002-2009 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.web;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.samples.petclinic.Visit;
import org.springframework.web.servlet.view.feed.AbstractAtomFeedView;
import com.sun.syndication.feed.atom.Content;
import com.sun.syndication.feed.atom.Entry;
import com.sun.syndication.feed.atom.Feed;
/**
* A view creating a Atom representation from a list of Visit objects.
*
* @author Alef Arendsen
* @author Arjen Poutsma
*/
public class VisitsAtomView extends AbstractAtomFeedView {
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
feed.setId("tag:springsource.com");
feed.setTitle("Pet ClinicService Visits");
@SuppressWarnings("unchecked")
List<Visit> visits = (List<Visit>) model.get("visits");
for (Visit visit : visits) {
Date date = visit.getDate().toDate();
if (feed.getUpdated() == null || date.compareTo(feed.getUpdated()) > 0) {
feed.setUpdated(date);
}
}
}
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response) throws Exception {
@SuppressWarnings("unchecked")
List<Visit> visits = (List<Visit>) model.get("visits");
List<Entry> entries = new ArrayList<Entry>(visits.size());
for (Visit visit : visits) {
Entry entry = new Entry();
String date = String.format("%1$tY-%1$tm-%1$td", visit.getDate().toDate());
// see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
entry.setId(String.format("tag:springsource.com,%s:%d", date, visit.getId()));
entry.setTitle(String.format("%s visit on %s", visit.getPet().getName(), date));
entry.setUpdated(visit.getDate().toDate());
Content summary = new Content();
summary.setValue(visit.getDescription());
entry.setSummary(summary);
entries.add(entry);
}
return entries;
}
}
/**
*
* The classes in this package represent PetClinic's web presentation layer.
*
*/
package org.springframework.samples.petclinic.web;
<html>
<body>
<p>
The Spring Data Binding framework, an internal library used by Spring Web Flow.
</p>
</body>
</html>
\ No newline at end of file
.navbar {
border-top: 4px solid #6db33f;
background-color: #34302d;
margin-bottom: 0px;
border-bottom: 0;
border-left: 0;
border-right: 0;
}
.navbar a.navbar-brand {
background: url("../images/spring-logo-dataflow.png") -1px -1px no-repeat;
margin: 12px 0 6px;
width: 229px;
height: 46px;
display: inline-block;
text-decoration: none;
padding: 0;
}
.navbar a.navbar-brand span {
display: block;
width: 229px;
height: 46px;
background: url("../images/spring-logo-dataflow.png") -1px -48px no-repeat;
opacity: 0;
-moz-transition: opacity 0.12s ease-in-out;
-webkit-transition: opacity 0.12s ease-in-out;
-o-transition: opacity 0.12s ease-in-out;
}
.navbar a:hover.navbar-brand span {
opacity: 1;
}
.navbar li > a, .navbar-text {
font-family: "montserratregular", sans-serif;
text-shadow: none;
font-size: 14px;
/* line-height: 14px; */
padding: 28px 20px;
transition: all 0.15s;
-webkit-transition: all 0.15s;
-moz-transition: all 0.15s;
-o-transition: all 0.15s;
-ms-transition: all 0.15s;
}
.navbar li > a {
text-transform: uppercase;
}
.navbar .navbar-text {
margin-top: 0;
margin-bottom: 0;
}
.navbar li:hover > a {
color: #eeeeee;
background-color: #6db33f;
}
.navbar-toggle {
border-width: 0;
.icon-bar + .icon-bar {
margin-top: 3px;
}
.icon-bar {
width: 19px;
height: 3px;
}
}
/*
* Copyright 2016 the original author or authors.
*
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@icon-font-path: "../../webjars/bootstrap/fonts/";
@spring-green: #6db33f;
@spring-dark-green: #5fa134;
@spring-brown: #34302D;
@spring-grey: #838789;
@spring-light-grey: #f1f1f1;
@body-bg: @spring-light-grey;
@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-hover-bg: @spring-green;
@navbar-default-toggle-icon-bar-bg: @spring-light-grey;
@navbar-default-toggle-hover-bg: transparent;
@navbar-default-link-active-bg: @spring-green;
@border-radius-base: 0;
@border-radius-large: 0;
@border-radius-small: 0;
@btn-default-color: @spring-light-grey;
@btn-default-bg: @spring-brown;
@btn-default-border: @spring-green;
@nav-tabs-active-link-hover-color: @spring-light-grey;
@nav-tabs-active-link-hover-bg: @spring-brown;
@nav-tabs-active-link-hover-border-color: @spring-brown;
@nav-tabs-border-color: @spring-brown;
@pagination-active-bg: @spring-brown;
@pagination-active-border: @spring-green;
@table-border-color: @spring-brown;
.table > thead > tr > th {
background-color: lighten(@spring-brown, 3%);
color: @spring-light-grey;
}
.table-filter {
background-color: @spring-brown;
padding: 9px 12px;
}
.nav > li > a {
color: @spring-grey;
}
.btn-default {
border-width: 2px;
transition: border 0.15s;
-webkit-transition: border 0.15s;
-moz-transition: border 0.15s;
-o-transition: border 0.15s;
-ms-transition: border 0.15s;
&:hover,
&:focus,
&:active,
&.active,
.open .dropdown-toggle& {
background-color: @spring-brown;
border-color: @spring-brown;
}
}
.container .text-muted {
margin: 20px 0;
}
code {
font-size: 80%;
}
.xd-container {
margin-top: 40px;
margin-bottom: 100px;
padding-left: 5px;
padding-right: 5px;
}
h1 {
margin-bottom: 15px
}
.index-page--subtitle {
font-size: 16px;
line-height: 24px;
margin: 0 0 30px;
}
.form-horizontal button.btn-inverse {
margin-left: 32px;
}
#job-params-modal .modal-dialog {
width: 90%;
margin-left:auto;
margin-right:auto;
}
[ng-cloak].splash {
display: block !important;
}
[ng-cloak] {
display: none;
}
.splash {
background: @spring-green;
color: @spring-brown;
display: none;
}
.error-page {
margin-top: 100px;
text-align: center;
}
.error-page .error-title {
font-size: 24px;
line-height: 24px;
margin: 30px 0 0;
}
table td {
vertical-align: middle;
}
table td .progress {
margin-bottom: 0;
}
table td.action-column {
width: 1px;
}
.help-block {
color: lighten(@text-color, 50%); // lighten the text some for contrast
}
.xd-containers {
font-size: 15px;
}
.cluster-view > table td {
vertical-align: top;
}
.cluster-view .label, .cluster-view .column-block {
display: block;
}
.cluster-view .input-group-addon {
width: 0%;
}
.cluster-view {
margin-bottom: 0;
}
.deployment-status-deployed {
.label-success;
}
.deployment-status-incomplete {
.label-warning;
}
.deployment-status-failed {
.label-danger;
}
.deployment-status-deploying {
.label-info
}
.deployment-status-na {
}
.container-details-table th {
background-color: lighten(@spring-brown, 3%);
color: @spring-light-grey;
}
.status-help-content-table td {
color: @spring-brown;
}
.alert-success {
.alert-variant(fade(@alert-success-bg, 70%); @alert-success-border; @alert-success-text);
}
.alert-info {
.alert-variant(fade(@alert-info-bg, 70%); @alert-info-border; @alert-info-text);
}
.alert-warning {
.alert-variant(fade(@alert-warning-bg, 70%); @alert-warning-border; @alert-warning-text);
}
.alert-danger {
.alert-variant(fade(@alert-danger-bg, 70%); @alert-danger-border; @alert-danger-text);
}
.myspinner {
animation-name: spinner;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-timing-function: linear;
-webkit-transform-origin: 49% 50%;
-webkit-animation-name: spinner;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
hr {
border-top: 1px dotted @spring-brown;
}
@import "typography.less";
@import "header.less";
@import "responsive.less";
@media (max-width: 768px) {
.navbar-toggle {
position:absolute;
z-index: 9999;
left:0px;
top:0px;
}
.navbar a.navbar-brand {
display: block;
margin: 0 auto 0 auto;
width: 148px;
height: 50px;
float: none;
background: url("../images/spring-logo-dataflow-mobile.png") 0 center no-repeat;
}
.homepage-billboard .homepage-subtitle {
font-size: 21px;
line-height: 21px;
}
.navbar a.navbar-brand span {
display: none;
}
.navbar {
border-top-width: 0;
}
.xd-container {
margin-top: 20px;
margin-bottom: 30px;
}
.index-page--subtitle {
margin-top: 10px;
margin-bottom: 30px;
}
}
@font-face {
font-family: 'varela_roundregular';
src: url('../fonts/varela_round-webfont.eot');
src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/varela_round-webfont.woff') format('woff'),
url('../fonts/varela_round-webfont.ttf') format('truetype'),
url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'montserratregular';
src: url('../fonts/montserrat-webfont.eot');
src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/montserrat-webfont.woff') format('woff'),
url('../fonts/montserrat-webfont.ttf') format('truetype'),
url('../fonts/montserrat-webfont.svg#montserratregular') format('svg');
font-weight: normal;
font-style: normal;
}
body, h1, h2, h3, p, input {
margin: 0;
font-weight: 400;
font-family: "varela_roundregular", sans-serif;
color: #34302d;
}
h1 {
font-size: 24px;
line-height: 30px;
font-family: "montserratregular", sans-serif;
}
h2 {
font-size: 18px;
font-weight: 700;
line-height: 24px;
margin-bottom: 10px;
font-family: "montserratregular", sans-serif;
}
h3 {
font-size: 16px;
line-height: 24px;
margin-bottom: 10px;
font-weight: 700;
}
p {
//font-size: 15px;
//line-height: 24px;
}
strong {
font-weight: 700;
font-family: "montserratregular", sans-serif;
}
<?xml version="1.0"?>
<!-- Custom aspects for the PetClinic sample application -->
<aspectj>
<weaver>
<include within="org.springframework.samples.petclinic..*"/>
</weaver>
<aspects>
<aspect name="org.springframework.samples.petclinic.aspects.UsageLogAspect"/>
<concrete-aspect name="org.springframework.samples.petclinic.aspects.ApplicationTraceAspect"
extends="org.springframework.samples.petclinic.aspects.AbstractTraceAspect">
<pointcut name="traced" expression="execution(* org.springframework.samples..*.*(..))"/>
</concrete-aspect>
</aspects>
</aspectj>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="PetClinic" transaction-type="RESOURCE_LOCAL"/>
</persistence>
# database init, supports mysql too
database=mysql
spring.datasource.url=jdbc:mysql://localhost/petclinic
spring.datasource.username=root
spring.datasource.password=petclinic
# Uncomment this the first time the app runs
# spring.datasource.initialization-mode=always
# database init, supports mysql too
database=hsqldb
spring.datasource.schema=classpath*:db/${database}/schema.sql
spring.datasource.data=classpath*:db/${database}/data.sql
# Web
spring.thymeleaf.mode=HTML
# JPA
spring.jpa.hibernate.ddl-auto=none
# Internationalization
spring.messages.basename=messages/messages
# Actuator / Management
management.endpoints.web.base-path=/manage
management.endpoints.web.exposure.include=*
# Logging
logging.level.org.springframework=INFO
# logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE
# Maximum time static resources should be cached
spring.resources.cache.cachecontrol.max-age=12h
|\ _,,,--,,_
/,`.-'`' ._ \-;;,_
_______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______
| | '---''(_/._)-'(_\_) | | | | | | | | |
| _ | ___|_ _| | | | | |_| | | | __ _ _
| |_| | |___ | | | | | | | | | | \ \ \ \
| ___| ___| | | | _| |___| | _ | | _| \ \ \ \
| | | |___ | | | |_| | | | | | | |_ ) ) ) )
|___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
==================================================================/_/_/_/
:: Built with Spring Boot :: ${spring-boot.version}
......@@ -33,21 +33,21 @@ INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '
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', '2000-09-07', 1, 1);
INSERT INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);
INSERT INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3);
INSERT INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3);
INSERT INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4);
INSERT INTO pets VALUES (6, 'George', '2000-01-20', 4, 5);
INSERT INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6);
INSERT INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6);
INSERT INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7);
INSERT INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8);
INSERT INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9);
INSERT INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10);
INSERT INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10);
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 visits VALUES (1, 7, '1996-03-04', 'rabies shot');
INSERT INTO visits VALUES (2, 8, '1996-03-04', 'rabies shot');
INSERT INTO visits VALUES (3, 8, '1996-06-04', 'neutered');
INSERT INTO visits VALUES (4, 7, '1996-09-04', 'spayed');
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');
drop table vet_specialties if exists;
drop table vets 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;
CREATE TABLE vets (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)
);
CREATE INDEX vets_last_name ON vets(last_name);
CREATE TABLE specialties (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX specialties_name ON specialties(name);
CREATE TABLE vet_specialties (
vet_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);
CREATE TABLE types (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX types_name ON types(name);
CREATE TABLE owners (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30),
address VARCHAR(255),
city VARCHAR(80),
telephone VARCHAR(20)
);
CREATE INDEX owners_last_name ON owners(last_name);
CREATE TABLE pets (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(30),
birth_date DATE,
type_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
);
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);
CREATE TABLE visits (
id INTEGER IDENTITY PRIMARY KEY,
pet_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);
DROP TABLE vet_specialties IF EXISTS;
DROP TABLE vets 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;
CREATE TABLE vets (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)
);
CREATE INDEX vets_last_name ON vets (last_name);
CREATE TABLE specialties (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX specialties_name ON specialties (name);
CREATE TABLE vet_specialties (
vet_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);
CREATE TABLE types (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX types_name ON types (name);
CREATE TABLE owners (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR_IGNORECASE(30),
address VARCHAR(255),
city VARCHAR(80),
telephone VARCHAR(20)
);
CREATE INDEX owners_last_name ON owners (last_name);
CREATE TABLE pets (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(30),
birth_date DATE,
type_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
);
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);
CREATE TABLE visits (
id INTEGER IDENTITY PRIMARY KEY,
pet_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);
......@@ -47,7 +47,7 @@ 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 visits VALUES (1, 7, '1996-03-04', 'rabies shot');
INSERT IGNORE INTO visits VALUES (2, 8, '1996-03-04', 'rabies shot');
INSERT IGNORE INTO visits VALUES (3, 8, '1996-06-04', 'neutered');
INSERT IGNORE INTO visits VALUES (4, 7, '1996-09-04', 'spayed');
INSERT IGNORE INTO visits VALUES (1, 7, '2010-03-04', 'rabies shot');
INSERT IGNORE INTO visits VALUES (2, 8, '2011-03-04', 'rabies shot');
INSERT IGNORE INTO visits VALUES (3, 8, '2009-06-04', 'neutered');
INSERT IGNORE INTO visits VALUES (4, 7, '2008-09-04', 'spayed');