Reorganizadas las clases y renombradas a cheapy

This commit is contained in:
abemorcardc 2021-03-18 00:35:57 +01:00
parent 6fe1d6b1fb
commit 48ae594b90
22 changed files with 39 additions and 165 deletions

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId> <groupId>org.springframework.samples</groupId>
<artifactId>spring-petclinic</artifactId> <artifactId>spring-cheapy</artifactId>
<version>2.4.2</version> <version>2.4.2</version>
<parent> <parent>
@ -12,7 +12,7 @@
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version> <version>2.4.2</version>
</parent> </parent>
<name>petclinic</name> <name>cheapy</name>
<properties> <properties>

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic; package org.springframework.cheapy;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -26,10 +26,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* *
*/ */
@SpringBootApplication(proxyBeanMethods = false) @SpringBootApplication(proxyBeanMethods = false)
public class PetClinicApplication { public class CheapyApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(PetClinicApplication.class, args); SpringApplication.run(CheapyApplication.class, args);
} }
} }

View file

@ -13,7 +13,7 @@
* 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.cheapy.model;
import java.io.Serializable; import java.io.Serializable;

View file

@ -13,7 +13,7 @@
* 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.cheapy.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;

View file

@ -13,7 +13,7 @@
* 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.owner; package org.springframework.cheapy.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -32,7 +32,6 @@ import javax.validation.constraints.NotEmpty;
import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator; import org.springframework.beans.support.PropertyComparator;
import org.springframework.core.style.ToStringCreator; import org.springframework.core.style.ToStringCreator;
import org.springframework.samples.petclinic.model.Person;
/** /**
* Simple JavaBean domain object representing an owner. * Simple JavaBean domain object representing an owner.

View file

@ -13,7 +13,7 @@
* 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.cheapy.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;

View file

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

View file

@ -13,10 +13,11 @@
* 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.owner; package org.springframework.cheapy.repository;
import java.util.Collection; import java.util.Collection;
import org.springframework.cheapy.model.Owner;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.system; package org.springframework.cheapy.system;
import javax.cache.configuration.MutableConfiguration; import javax.cache.configuration.MutableConfiguration;

View file

@ -13,7 +13,7 @@
* 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.system; package org.springframework.cheapy.system;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.GetMapping;
* Also see how a view that resolves to "error" has been added ("error.html"). * Also see how a view that resolves to "error" has been added ("error.html").
*/ */
@Controller @Controller
class CrashController { public class CrashController {
@GetMapping("/oups") @GetMapping("/oups")
public String triggerException() { public String triggerException() {

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.system; package org.springframework.cheapy.system;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;

View file

@ -13,8 +13,10 @@
* 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.owner; package org.springframework.cheapy.web;
import org.springframework.cheapy.model.Owner;
import org.springframework.cheapy.repository.OwnerRepository;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
@ -36,7 +38,7 @@ import java.util.Map;
* @author Michael Isvy * @author Michael Isvy
*/ */
@Controller @Controller
class OwnerController { public class OwnerController {
private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm"; private static final String VIEWS_OWNER_CREATE_OR_UPDATE_FORM = "owners/createOrUpdateOwnerForm";

View file

@ -1,15 +1,9 @@
__^__ __^__
( ___ )------------------------------------( ___ )
|\ _,,,--,,_ | / | | \ |
/,`.-'`' ._ \-;;,_ | / | Cheapy | \ |
_______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______ |___| |___|
| | '---''(_/._)-'(_\_) | | | | | | | | | (_____)------------------------------------(_____)
| _ | ___|_ _| | | | | |_| | | | __ _ _
| |_| | |___ | | | | | | | | | | \ \ \ \
| ___| ___| | | | _| |___| | _ | | _| \ \ \ \
| | | |___ | | | |_| | | | | | | |_ ) ) ) )
|___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
==================================================================/_/_/_/
:: Built with Spring Boot :: ${spring-boot.version} :: Built with Spring Boot :: ${spring-boot.version}

View file

@ -8,9 +8,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <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}"> <link rel="shortcut icon" type="image/x-icon" th:href="@{/resources/images/cheapy.png}">
<title>PetClinic :: a Spring Framework demonstration</title> <title>Cheapy</title>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>

View file

@ -1,38 +0,0 @@
<html xmlns:th="https://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', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate', 'date')}" />
<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=${pet['new']} ? 'Add Pet' : 'Update Pet'"
class="btn btn-default" type="submit" th:text="${text}">Add
Pet</button>
</div>
</div>
</form>
</body>
</html>

View file

@ -1,61 +0,0 @@
<html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">
<body>
<h2>
<th:block th:if="${visit['new']}">New </th:block>
Visit
</h2>
<b>Pet</b>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Birth Date</th>
<th>Type</th>
<th>Owner</th>
</tr>
</thead>
<tr>
<td th:text="${pet.name}"></td>
<td
th:text="${#temporals.format(pet.birthDate, 'yyyy-MM-dd')}"></td>
<td th:text="${pet.type}"></td>
<td
th:text="${pet.owner?.firstName + ' ' + pet.owner?.lastName}"></td>
</tr>
</table>
<form th:object="${visit}" class="form-horizontal" method="post">
<div class="form-group has-feedback">
<input
th:replace="~{fragments/inputField :: input ('Date', 'date', 'date')}" />
<input
th:replace="~{fragments/inputField :: input ('Description', 'description', 'text')}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="petId" th:value="${pet.id}" />
<button class="btn btn-default" type="submit">Add Visit</button>
</div>
</div>
</form>
<br />
<b>Previous Visits</b>
<table class="table table-striped">
<tr>
<th>Date</th>
<th>Description</th>
</tr>
<tr th:if="${!visit['new']}" th:each="visit : ${pet.visits}">
<td th:text="${#temporals.format(visit.date, 'yyyy-MM-dd')}"></td>
<td th:text=" ${visit.description}"></td>
</tr>
</table>
</body>
</html>

View file

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="https://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>
</body>
</html>

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic; package org.springframework.cheapy.integration;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.model; package org.springframework.cheapy.model;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
@ -23,6 +23,7 @@ import javax.validation.ConstraintViolation;
import javax.validation.Validator; import javax.validation.Validator;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.cheapy.model.Person;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

View file

@ -14,12 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.service; package org.springframework.cheapy.service;
import java.util.Collection; import java.util.Collection;
import org.springframework.cheapy.model.BaseEntity;
import org.springframework.orm.ObjectRetrievalFailureException; import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.samples.petclinic.model.BaseEntity;
/** /**
* Utility methods for handling entities. Separate from the BaseEntity class mainly * Utility methods for handling entities. Separate from the BaseEntity class mainly
@ -27,7 +27,7 @@ import org.springframework.samples.petclinic.model.BaseEntity;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Sam Brannen * @author Sam Brannen
* @see org.springframework.samples.petclinic.model.BaseEntity * @see org.springframework.cheapy.model.BaseEntity
* @since 29.10.2003 * @since 29.10.2003
*/ */
public abstract class EntityUtils { public abstract class EntityUtils {

View file

@ -14,12 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.system; package org.springframework.cheapy.system;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.cheapy.system.CrashController;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.samples.petclinic.owner; package org.springframework.cheapy.web;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collections; import java.util.Collections;
@ -28,6 +28,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.cheapy.model.Owner;
import org.springframework.cheapy.repository.OwnerRepository;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;