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 150 additions and 90 deletions
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -13,112 +13,68 @@ ...@@ -13,112 +13,68 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.model; package org.springframework.samples.petclinic.visit;
import org.hibernate.validator.constraints.NotEmpty; import java.time.LocalDate;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.validation.constraints.NotEmpty;
import javax.persistence.TemporalType;
import java.util.Date; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.BaseEntity;
/** /**
* Simple JavaBean domain object representing a visit. * Simple JavaBean domain object representing a visit.
* *
* @author Ken Krebs * @author Ken Krebs
* @author Dave Syer
*/ */
@Entity @Entity
@Table(name = "visits") @Table(name = "visits")
public class Visit extends BaseEntity { public class Visit extends BaseEntity {
/**
* Holds value of property date.
*/
@Column(name = "visit_date") @Column(name = "visit_date")
@Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy/MM/dd") private LocalDate date;
private Date date;
/**
* Holds value of property description.
*/
@NotEmpty @NotEmpty
@Column(name = "description") @Column(name = "description")
private String description; private String description;
/** @Column(name = "pet_id")
* Holds value of property pet. private Integer petId;
*/
@ManyToOne
@JoinColumn(name = "pet_id")
private Pet pet;
/** /**
* Creates a new instance of Visit for the current date * Creates a new instance of Visit for the current date
*/ */
public Visit() { public Visit() {
this.date = new Date(); this.date = LocalDate.now();
} }
public LocalDate getDate() {
/**
* Getter for property date.
*
* @return Value of property date.
*/
public Date getDate() {
return this.date; return this.date;
} }
/** public void setDate(LocalDate date) {
* Setter for property date.
*
* @param date New value of property date.
*/
public void setDate(Date date) {
this.date = date; this.date = date;
} }
/**
* Getter for property description.
*
* @return Value of property description.
*/
public String getDescription() { public String getDescription() {
return this.description; return this.description;
} }
/**
* Setter for property description.
*
* @param description New value of property description.
*/
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
/** public Integer getPetId() {
* Getter for property pet. return this.petId;
*
* @return Value of property pet.
*/
public Pet getPet() {
return this.pet;
} }
/** public void setPetId(Integer petId) {
* Setter for property pet. this.petId = petId;
*
* @param pet New value of property pet.
*/
public void setPet(Pet pet) {
this.pet = pet;
} }
} }
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -13,18 +13,18 @@ ...@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.visit;
import java.util.List; import java.util.List;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import org.springframework.samples.petclinic.model.BaseEntity; import org.springframework.samples.petclinic.model.BaseEntity;
import org.springframework.samples.petclinic.model.Visit;
/** /**
* Repository class for <code>Visit</code> domain objects All method names are compliant with Spring Data naming * Repository class for <code>Visit</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 * conventions so this interface can easily be extended for Spring Data.
* See: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation
* *
* @author Ken Krebs * @author Ken Krebs
* @author Juergen Hoeller * @author Juergen Hoeller
......
package org.springframework.samples.petclinic.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class WelcomeController {
@RequestMapping("/")
public String welcome() {
return "welcome";
}
}
/**
* The classes in this package represent PetClinic's web presentation layer.
*/
package org.springframework.samples.petclinic.web;
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
@import "META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less";
@icon-font-path: "../../webjars/bootstrap/fonts/"; @icon-font-path: "../../webjars/bootstrap/fonts/";
@spring-green: #6db33f; @spring-green: #6db33f;
......
# 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
...@@ -13,11 +13,13 @@ spring.jpa.hibernate.ddl-auto=none ...@@ -13,11 +13,13 @@ spring.jpa.hibernate.ddl-auto=none
spring.messages.basename=messages/messages spring.messages.basename=messages/messages
# Actuator / Management # Actuator / Management
management.contextPath=/manage management.endpoints.web.base-path=/manage
management.endpoints.web.exposure.include=*
# Logging # Logging
logging.level.org.springframework=INFO logging.level.org.springframework=INFO
logging.level.org.springframework.web=DEBUG # logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE
# Active Spring profiles # Maximum time static resources should be cached
spring.profiles.active=production spring.resources.cache.cachecontrol.max-age=12h
...@@ -4,21 +4,14 @@ ...@@ -4,21 +4,14 @@
@author Sam Brannen @author Sam Brannen
@author Costin Leau @author Costin Leau
@author Dave Syer
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x), 1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x),
which can be found here: http://dev.mysql.com/downloads/ which can be found here: https://dev.mysql.com/downloads/. Or run the
"docker-compose.yml" from the root of the project (if you have docker installed
locally).
2) Download Connector/J, the MySQL JDBC driver (e.g., Connector/J 5.1.x), which 2) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql"
can be found here: http://dev.mysql.com/downloads/connector/j/ scripts (or set "spring.datasource.initialize=true" the first time you run the app).
Copy the Connector/J JAR file (e.g., mysql-connector-java-5.1.5-bin.jar) into
the db/mysql directory. Alternatively, uncomment the mysql-connector from the
Petclinic pom.
3) Create the PetClinic database and user by executing the "db/mysql/initDB.sql"
script.
4) Open "src/main/resources/spring/data-access.properties"; comment out all properties in the
"HSQL Settings" section; uncomment all properties in the "MySQL Settings"
section.
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}"> <html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">
<body> <body>
<img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/> <img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
......
<html> <html>
<body> <body>
<form> <form>
<th:block th:fragment="input (label, name)"> <th:block th:fragment="input (label, name, type)">
<div th:with="valid=${!#fields.hasErrors(name)}" <div th:with="valid=${!#fields.hasErrors(name)}"
th:class="${'form-group' + (valid ? '' : ' has-error')}" th:class="${'form-group' + (valid ? '' : ' has-error')}"
class="form-group"> class="form-group">
<label class="col-sm-2 control-label" th:text="${label}">Label</label> <label class="col-sm-2 control-label" th:text="${label}">Label</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input class="form-control" type="text" <div th:switch="${type}">
th:field="*{__${name}__}" /> <input th:case="'text'" class="form-control" type="text" th:field="*{__${name}__}" />
<input th:case="'date'" class="form-control" type="text" th:field="*{__${name}__}"
placeholder="YYYY-MM-DD" title="Enter a date in this format: YYYY-MM-DD"
pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))"/>
</div>
<span th:if="${valid}" <span th:if="${valid}"
class="glyphicon glyphicon-ok form-control-feedback" class="glyphicon glyphicon-ok form-control-feedback"
aria-hidden="true"></span> aria-hidden="true"></span>
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<span>Veterinarians</span> <span>Veterinarians</span>
</li> </li>
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','th-warning-sign','Error')"> <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 class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
<span>Error</span> <span>Error</span>
</li> </li>
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="container xd-container"> <div class="container xd-container">
<div th:replace="${template}"/> <th:block th:include="${template}"/>
<br/> <br/>
<br/> <br/>
......
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}"> th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body> <body>
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
<form th:object="${owner}" class="form-horizontal" id="add-owner-form" method="post"> <form th:object="${owner}" class="form-horizontal" id="add-owner-form" method="post">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<input <input
th:replace="~{fragments/inputField :: input ('First Name', 'firstName')}" /> th:replace="~{fragments/inputField :: input ('First Name', 'firstName', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Last Name', 'lastName')}" /> th:replace="~{fragments/inputField :: input ('Last Name', 'lastName', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Address', 'address')}" /> th:replace="~{fragments/inputField :: input ('Address', 'address', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('City', 'city')}" /> th:replace="~{fragments/inputField :: input ('City', 'city', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Telephone', 'telephone')}" /> th:replace="~{fragments/inputField :: input ('Telephone', 'telephone', 'text')}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
......
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}"> th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body> <body>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<form th:object="${owner}" th:action="@{/owners}" method="get" <form th:object="${owner}" th:action="@{/owners}" method="get"
class="form-horizontal" id="search-owner-form"> class="form-horizontal" id="search-owner-form">
<div class="form-group"> <div class="form-group">
<div class="control-group" id="lastName"> <div class="control-group" id="lastNameGroup">
<label class="col-sm-2 control-label">Last name </label> <label class="col-sm-2 control-label">Last name </label>
<div class="col-sm-10"> <div class="col-sm-10">
<input class="form-control" th:field="*{lastName}" size="30" <input class="form-control" th:field="*{lastName}" size="30"
......
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}"> th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body> <body>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<dd th:text="${pet.name}" /></dd> <dd th:text="${pet.name}" /></dd>
<dt>Birth Date</dt> <dt>Birth Date</dt>
<dd <dd
th:text="${#calendars.format(pet.birthDate, 'yyyy-MM-dd')}" /></dd> th:text="${#temporals.format(pet.birthDate, 'yyyy-MM-dd')}" /></dd>
<dt>Type</dt> <dt>Type</dt>
<dd th:text="${pet.type}" /></dd> <dd th:text="${pet.type}" /></dd>
</dl> </dl>
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</tr> </tr>
</thead> </thead>
<tr th:each="visit : ${pet.visits}"> <tr th:each="visit : ${pet.visits}">
<td th:text="${#calendars.format(visit.date, 'yyyy-MM-dd')}"></td> <td th:text="${#temporals.format(visit.date, 'yyyy-MM-dd')}"></td>
<td th:text="${visit?.description}"></td> <td th:text="${visit?.description}"></td>
</tr> </tr>
<tr> <tr>
...@@ -80,4 +80,4 @@ ...@@ -80,4 +80,4 @@
</body> </body>
</html> </html>
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'owners')}"> <html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body> <body>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<tbody> <tbody>
<tr th:each="owner : ${selections}"> <tr th:each="owner : ${selections}">
<td> <td>
<a th:href="@{owners/__${owner.id}__}" th:text="${owner.firstName + ' ' + owner.lastName}"/></a> <a th:href="@{/owners/__${owner.id}__}" th:text="${owner.firstName + ' ' + owner.lastName}"/></a>
</td> </td>
<td th:text="${owner.address}"/> <td th:text="${owner.address}"/>
<td th:text="${owner.city}"/> <td th:text="${owner.city}"/>
......
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}"> th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body> <body>
...@@ -17,16 +17,16 @@ ...@@ -17,16 +17,16 @@
</div> </div>
</div> </div>
<input <input
th:replace="~{fragments/inputField :: input ('Name', 'name')}" /> th:replace="~{fragments/inputField :: input ('Name', 'name', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate')}" /> th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate', 'date')}" />
<input <input
th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" /> th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<button <button
th:with="text=${owner['new']} ? 'Add Pet' : 'Update Pet'" th:with="text=${pet['new']} ? 'Add Pet' : 'Update Pet'"
class="btn btn-default" type="submit" th:text="${text}">Add class="btn btn-default" type="submit" th:text="${text}">Add
Pet</button> Pet</button>
</div> </div>
......
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}"> th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body> <body>
...@@ -19,26 +19,26 @@ ...@@ -19,26 +19,26 @@
</tr> </tr>
</thead> </thead>
<tr> <tr>
<td th:text="${visit.pet.name}" /></td> <td th:text="${pet.name}" /></td>
<td <td
th:text="${#calendars.format(visit.pet.birthDate, 'yyyy-MM-dd')}" /></td> th:text="${#temporals.format(pet.birthDate, 'yyyy-MM-dd')}" /></td>
<td th:text="${visit.pet.type}" /></td> <td th:text="${pet.type}" /></td>
<td <td
th:text="${visit.pet.owner?.firstName + ' ' + visit.pet.owner?.lastName}" /></td> th:text="${pet.owner?.firstName + ' ' + pet.owner?.lastName}" /></td>
</tr> </tr>
</table> </table>
<form th:object="${visit}" class="form-horizontal" method="post"> <form th:object="${visit}" class="form-horizontal" method="post">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<input <input
th:replace="~{fragments/inputField :: input ('Date', 'date')}" /> th:replace="~{fragments/inputField :: input ('Date', 'date', 'date')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Description', 'description')}" /> th:replace="~{fragments/inputField :: input ('Description', 'description', 'text')}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="petId" th:value="${visit.pet.id}" /> <input type="hidden" name="petId" th:value="${pet.id}" />
<button class="btn btn-default" type="submit">Add Visit</button> <button class="btn btn-default" type="submit">Add Visit</button>
</div> </div>
</div> </div>
...@@ -51,11 +51,11 @@ ...@@ -51,11 +51,11 @@
<th>Date</th> <th>Date</th>
<th>Description</th> <th>Description</th>
</tr> </tr>
<tr th:if="${!visit['new']}" th:each="visit : ${visit.pet.visits}"> <tr th:if="${!visit['new']}" th:each="visit : ${pet.visits}">
<td th:text="${#calendars.format(visit.date, 'yyyy-MM-dd')}" /></td> <td th:text="${#temporals.format(visit.date, 'yyyy-MM-dd')}" /></td>
<td th:text=" ${visit.description}" /></td> <td th:text=" ${visit.description}" /></td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" <html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'vets')}"> th:replace="~{fragments/layout :: layout (~{::body},'vets')}">
<body> <body>
...@@ -23,14 +23,5 @@ ...@@ -23,14 +23,5 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="table-buttons">
<tr>
<td><a th:href="@{/vets.html}">View
as XML</a></td>
<td><a th:href="@{/vets.json}">View as JSON</a></td>
</tr>
</table>
</body> </body>
</html> </html>
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'home')}"> <html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'home')}">
<body> <body>
......
#List of preProcessors
preProcessors=lessCssImport
#List of postProcessors
postProcessors=less4j
\ No newline at end of file