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 0 additions and 553 deletions
package org.springframework.samples.petclinic.appointments;
import java.util.Date;
public class AppointmentForm {
private Long doctor;
private Long owner;
private String pet;
private Date date;
private Date time;
private String notes;
public Long getDoctor() {
return doctor;
}
public void setDoctor(Long doctor) {
this.doctor = doctor;
}
public Long getOwner() {
return owner;
}
public void setOwner(Long owner) {
this.owner = owner;
}
public String getPet() {
return pet;
}
public void setPet(String pet) {
this.pet = pet;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
}
\ No newline at end of file
package org.springframework.samples.petclinic.appointments;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Appointments {
private Map<String, List<Appointment>> vetAppointments = new LinkedHashMap<String, List<Appointment>>();
public Map<String, List<Appointment>> getAllByVet() {
return vetAppointments;
}
}
package org.springframework.samples.petclinic.appointments;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/appointments")
public class AppointmentsController {
private AppointmentBook appointmentBook;
@Autowired
public AppointmentsController(AppointmentBook appointmentBook) {
this.appointmentBook = appointmentBook;
}
@RequestMapping(method = RequestMethod.GET)
public Appointments get() {
return appointmentBook.getAppointmentsForToday();
}
@RequestMapping(value="/{day}", method = RequestMethod.GET)
public Appointments getForDay(@PathVariable Date day) {
return appointmentBook.getAppointmentsForDay(day);
}
@RequestMapping(value="/new", method = RequestMethod.GET)
public AppointmentForm getNewForm() {
return new AppointmentForm();
}
@RequestMapping(method = RequestMethod.POST)
public String post(AppointmentForm form) {
appointmentBook.createAppointment(form);
return "redirect:/appointments";
}
}
package org.springframework.samples.petclinic.appointments;
import java.util.Date;
import org.springframework.stereotype.Repository;
@Repository
public class StubAppointmentBook implements AppointmentBook {
public Appointments getAppointmentsForDay(Date day) {
return new Appointments();
}
public Appointments getAppointmentsForToday() {
return new Appointments();
}
public Long createAppointment(AppointmentForm form) {
return 1L;
}
}
package org.springframework.samples.petclinic.owners;
public class Owner {
private Long id;
private String firstName;
private String lastName;
private String address;
private String city;
private String phone;
public Owner() {
}
public Owner(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
\ No newline at end of file
package org.springframework.samples.petclinic.owners;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.util.ExternalContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value="/owners/{owner}")
public class OwnerController {
private final OwnerRepository repository;
@Autowired
public OwnerController(OwnerRepository repository) {
this.repository = repository;
}
@RequestMapping(method=RequestMethod.GET)
public String get(@PathVariable Long owner, Model model) {
model.addAttribute(repository.getOwner(owner));
return "owner";
}
@RequestMapping(value="/edit", method=RequestMethod.GET)
public Owner getEditForm(@PathVariable Long owner) {
return repository.getOwner(owner);
}
@RequestMapping(method = RequestMethod.PUT)
public void put(Owner owner, ExternalContext response) {
repository.saveOwner(owner);
response.redirect(owner.getId());
}
}
\ No newline at end of file
package org.springframework.samples.petclinic.owners;
import java.util.Collection;
public interface OwnerRepository {
Collection<Owner> findOwnersByLastName(String lastName);
Owner getOwner(Long id);
Long saveOwner(Owner owner);
}
\ No newline at end of file
package org.springframework.samples.petclinic.owners;
public class OwnerSearchForm {
private String lastName;
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
package org.springframework.samples.petclinic.owners;
import java.util.Collection;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/owners")
public class OwnersController {
private final OwnerRepository repository;
@Autowired
public OwnersController(OwnerRepository repository) {
this.repository = repository;
}
@RequestMapping(method = RequestMethod.GET)
public OwnerSearchForm get() {
return new OwnerSearchForm();
}
@RequestMapping(value="/search", method = RequestMethod.GET)
public Collection<Owner> getSearchResults(@RequestParam String lastName) {
return repository.findOwnersByLastName(lastName);
}
@RequestMapping(value="/new", method = RequestMethod.GET)
public Owner getNewForm() {
return new Owner();
}
@RequestMapping(method = RequestMethod.POST)
public String post(Owner owner) {
Long ownerId = repository.saveOwner(owner);
return "redirect:/owners/" + ownerId;
}
}
package org.springframework.samples.petclinic.owners;
import java.util.Collection;
import org.springframework.stereotype.Repository;
@Repository
public class StubOwnerRepository implements OwnerRepository {
public Collection<Owner> findOwnersByLastName(String lastName) {
return null;
}
public Owner getOwner(Long id) {
return new Owner(id);
}
public Long saveOwner(Owner owner) {
return 1L;
}
}
package org.springframework.samples.petclinic.owners.pets;
public enum Gender {
MALE, FEMALE
}
package org.springframework.samples.petclinic.owners.pets;
import java.util.Date;
import org.springframework.samples.petclinic.util.Measurement;
public class Pet {
private String name;
private String species;
private String breed;
private Gender gender;
private Date birthDate;
private Measurement weight;
public String getName() {
return name;
}
}
package org.springframework.samples.petclinic.owners.pets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.util.ExternalContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value="/owners/{owner}/pets/{pet}")
public class PetController {
private final PetRepository repository;
@Autowired
public PetController(PetRepository repository) {
this.repository = repository;
}
@RequestMapping(method=RequestMethod.GET)
public Pet get(Long owner, String pet) {
return repository.getPet(owner, pet);
}
@RequestMapping(value="/edit", method=RequestMethod.GET)
public Pet getEditForm(Long owner, String pet) {
return repository.getPet(owner, pet);
}
@RequestMapping(method = RequestMethod.PUT)
public void put(Pet pet, ExternalContext response) {
repository.savePet(pet);
response.redirect(pet.getName());
}
@RequestMapping(method = RequestMethod.DELETE)
public void delete(Long owner, String pet, ExternalContext context) {
context.forResource("owners").redirect(owner);
}
}
\ No newline at end of file
package org.springframework.samples.petclinic.owners.pets;
public interface PetRepository {
Pet getPet(Long owner, String name);
void savePet(Pet pet);
}
package org.springframework.samples.petclinic.owners.pets;
import org.springframework.stereotype.Repository;
@Repository
public class StubPetRepository implements PetRepository {
public Pet getPet(Long owner, String name) {
return null;
}
public void savePet(Pet pet) {
}
}
package org.springframework.samples.petclinic.util;
import org.springframework.ui.Model;
// This is an idea as a context object to make avail to @Controller methods to interact with Dispatcher
public interface ExternalContext {
Model getModel();
void selectView(String viewName);
void renderFragment(String fragment);
void redirect(Object resource);
ExternalContext forResource(Object resource);
Object getNativeRequest();
Object getNativeResponse();
}
package org.springframework.samples.petclinic.util;
import java.math.BigDecimal;
public class Measurement {
private BigDecimal amount;
private Unit unit;
}
package org.springframework.samples.petclinic.util;
public enum Unit {
POUNDS
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//LOGGER" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>>
<!-- Application Loggers -->
<logger name="org.springframework.samples.petclinic">
<level value="info" />
</logger>
<!-- 3rdparty Loggers -->
<logger name="org.springframework.core">
<level value="info" />
</logger>
<logger name="org.springframework.beans">
<level value="info" />
</logger>
<logger name="org.springframework.context">
<level value="info" />
</logger>
<logger name="org.springframework.web">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<h2>Add New Appointment</h2>
<form:form id="addNewForm" action="${pageContext.request.contextPath}/appointments" modelAttribute="appointment" method="post">
<form:label for="doctor" path="doctor">
Doctor
<form:input path="doctor" />
</form:label>
<form:label for="owner" path="owner">
Owner
<form:input path="owner" />
</form:label>
<form:label for="pet" path="pet">
Pet
<form:input path="pet" />
</form:label>
<form:label for="date" path="date">
Date
<form:input path="date" />
</form:label>
<form:label for="time" path="time">
Time
<form:input path="time" />
</form:label>
<form:label for="notes" path="notes">
Notes
<form:input path="notes" />
</form:label>
<input type="submit" value="Add" />
</form:form>
\ No newline at end of file