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
Select Git revision

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
Select Git revision
Show changes
Showing
with 0 additions and 372 deletions
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
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h2>Appointment Calendar</h2>
\ No newline at end of file
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<div id="sidebar">
<ul id="sub-nav">
<li><a href="${pageContext.request.contextPath}/appointments">Calendar</a></li>
<li><a href="${pageContext.request.contextPath}/appointments/new">Add New</a></li>
</ul>
</div>
<div id="main">
<tiles:insertAttribute name="main" />
</div>
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h2>Welcome to the Spring 3 Petclinic</h2>
<img id="petlogo" src="${pageContext.request.contextPath}/resources/images/pets.png" />
<p>
This sample application demonstrates many of the features Spring provides for web application development.
</p>
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ page session="false" %>
<html>
<head>
<title><tiles:insertAttribute name="title"/></title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/styles/main.css"/>
</head>
<body id="page-body">
<div id="page">
<div id="header">
<ul id="signin">
<c:choose>
<c:when test="${pageContext.request.userPrincipal != null}">
<p>Welcome ${pageContext.request.userPrincipal.name}</p>
<li><a href="<c:url value="/account/signout"/>">Sign Out</a></li>
</c:when>
<c:otherwise>
<li><a href="<c:url value="/account/signin"/>">Sign In</a></li>
</c:otherwise>
</c:choose>
</ul>
<div id="nav">
<ul>
<li><a href="${pageContext.request.contextPath}">Home</a></li>
<li><a href="${pageContext.request.contextPath}/appointments">Appointments</a></li>
<li><a href="${pageContext.request.contextPath}/owners">Owners</a></li>
</ul>
</div>
</div>
<div id="content">
<tiles:insertAttribute name="content"/>
</div>
<div id="footer">
<ul id="legal">
<li>Privacy Policy</li>
<li>Terms of Service</li>
</ul>
<p>(c) 2009 <a href="http://www.springsource.org">springsource.org</a></p>
</div>
</div>
</body>
</html>
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<h2>Add New Owner</h2>
<form:form id="addNewForm" action="${pageContext.request.contextPath}/owners" modelAttribute="owner" method="post">
<form:label for="firstName" path="firstName">
First Name
<form:input path="firstName" />
</form:label>
<form:label for="lastName" path="lastName">
Last Name
<form:input path="lastName" />
</form:label>
<input type="submit" value="Add" />
</form:form>
\ No newline at end of file
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<div id="sidebar">
<ul id="sub-nav">
<li><a href="${pageContext.request.contextPath}/owners">Search</a></li>
<li><a href="${pageContext.request.contextPath}/owners/new">Add New</a></li>
</ul>
</div>
<div id="main">
<tiles:insertAttribute name="main" />
</div>
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<h2>Owner Details</h2>
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<h2>Search Owners</h2>
<form:form id="searchForm" action="owners/search" modelAttribute="ownerSearchForm" method="get">
<form:label for="lastName" path="lastName">
Last Name
<form:input path="lastName" />
</form:label>
<input type="submit" value="Search" />
</form:form>
\ No newline at end of file