diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/application/OwnerService.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/application/OwnerService.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/application/PetService.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/application/PetService.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/Person.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/Person.java deleted file mode 100644 index b17ed0fa83d8978c8216905488c606428aa14e86..0000000000000000000000000000000000000000 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/Person.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2002-2013 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.customers.domain.model; - -import org.hibernate.validator.constraints.NotEmpty; -import org.springframework.samples.petclinic.customers.support.jpa.BaseEntity; - -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; - -/** - * Simple JavaBean domain object representing an person. - * - * @author Ken Krebs - * @author Maciej Szarlinski - */ -@MappedSuperclass -public class Person extends BaseEntity { - - @Column(name = "first_name") - @NotEmpty - protected String firstName; - - @Column(name = "last_name") - @NotEmpty - protected String lastName; - - public String getFirstName() { - return this.firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return this.lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - -} diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetType.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetType.java deleted file mode 100644 index 59065f5eb6e907eb02b3a03b5f5db288218f592a..0000000000000000000000000000000000000000 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2002-2013 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.customers.domain.model.pet; - -import org.springframework.samples.petclinic.customers.support.jpa.NamedEntity; - -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * @author Juergen Hoeller - * Can be Cat, Dog, Hamster... - */ -@Entity -@Table(name = "types") -public class PetType extends NamedEntity { - -} diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/owner/Owner.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java similarity index 79% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/owner/Owner.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java index a9ad0196dcf0474721579ef3c0bf8d87881afd7b..49fc96ea599f55eb78cefb59606b359e4b1ee2d7 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/owner/Owner.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.customers.domain.model.owner; +package org.springframework.samples.petclinic.customers.model; import java.util.ArrayList; import java.util.Collections; @@ -25,6 +25,9 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Digits; @@ -33,8 +36,6 @@ import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.PropertyComparator; import org.springframework.core.style.ToStringCreator; -import org.springframework.samples.petclinic.customers.domain.model.Person; -import org.springframework.samples.petclinic.customers.domain.model.pet.Pet; /** * Simple JavaBean domain object representing an owner. @@ -47,7 +48,20 @@ import org.springframework.samples.petclinic.customers.domain.model.pet.Pet; */ @Entity @Table(name = "owners") -public class Owner extends Person { +public class Owner { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "first_name") + @NotEmpty + private String firstName; + + @Column(name = "last_name") + @NotEmpty + private String lastName; + @Column(name = "address") @NotEmpty private String address; @@ -64,6 +78,26 @@ public class Owner extends Person { @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner") private Set<Pet> pets; + public Integer getId() { + return id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } + public String getAddress() { return this.address; } @@ -111,7 +145,6 @@ public class Owner extends Person { return new ToStringCreator(this) .append("id", this.getId()) - .append("new", this.isNew()) .append("lastName", this.getLastName()) .append("firstName", this.getFirstName()) .append("address", this.address) diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/owner/OwnerRepository.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java similarity index 94% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/owner/OwnerRepository.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java index 006fe3179bd5c8dcc4b8b96bd9578b7f1ac61f0a..73aad51101572678f52407112d71e6aa3a9a143d 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/owner/OwnerRepository.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.customers.domain.model.owner; +package org.springframework.samples.petclinic.customers.model; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/Pet.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java similarity index 59% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/Pet.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java index 13be6e18fa76b790dabad58aa03209760b6abe67..625ff7371da9423f2f5304020624ed468cb9e8a1 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/Pet.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java @@ -13,15 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.customers.domain.model.pet; +package org.springframework.samples.petclinic.customers.model; -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.springframework.samples.petclinic.customers.domain.model.owner.Owner; -import org.springframework.samples.petclinic.customers.support.jpa.NamedEntity; - -import javax.persistence.*; import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import com.fasterxml.jackson.annotation.JsonIgnore; + /** * Simple business object representing a pet. * @@ -32,7 +40,13 @@ import java.util.Date; */ @Entity @Table(name = "pets") -public class Pet extends NamedEntity { +public class Pet { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "name") + private String name; @Column(name = "birth_date") @Temporal(TemporalType.DATE) @@ -47,27 +61,43 @@ public class Pet extends NamedEntity { @JsonIgnore private Owner owner; - public void setBirthDate(Date birthDate) { - this.birthDate = birthDate; + public Integer getId() { + return id; + } + + public void setId(final Integer id) { + this.id = id; + } + + public String getName() { + return this.name; + } + + public void setName(final String name) { + this.name = name; } public Date getBirthDate() { return birthDate; } - public void setType(PetType type) { - this.type = type; + public void setBirthDate(final Date birthDate) { + this.birthDate = birthDate; } public PetType getType() { return type; } - public void setOwner(Owner owner) { - this.owner = owner; + public void setType(final PetType type) { + this.type = type; } public Owner getOwner() { return owner; } + + public void setOwner(final Owner owner) { + this.owner = owner; + } } diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetRepository.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java similarity index 95% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetRepository.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java index 06350a4678b1bfa215c2990ebe4ce29335b9b3a4..4473853e543825da2a8559775005c7ec401a9331 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetRepository.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.customers.domain.model.pet; +package org.springframework.samples.petclinic.customers.model; import java.util.List; import java.util.Optional; diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/BaseEntity.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java similarity index 68% rename from spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/BaseEntity.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java index c59a4384d79d9cd8fdf5d0c70601c5b5cf35e1b5..2074390160cd0b380576ea479a73196bc1ae12a6 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/BaseEntity.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java @@ -13,36 +13,38 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.visits.support.jpa; +package org.springframework.samples.petclinic.customers.model; +import javax.persistence.Column; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.MappedSuperclass; +import javax.persistence.Table; /** - * Simple JavaBean domain object with an id property. Used as a base class for objects needing this property. - * - * @author Ken Krebs * @author Juergen Hoeller + * Can be Cat, Dog, Hamster... */ -@MappedSuperclass -public class BaseEntity { +@Entity +@Table(name = "types") +public class PetType { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - protected Integer id; - + private Integer id; - public void setId(Integer id) { - this.id = id; - } + @Column(name = "name") + private String name; public Integer getId() { return id; } - public boolean isNew() { - return (this.id == null); + public void setId(final Integer id) { + this.id = id; } + public String getName() { + return this.name; + } } diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/BaseEntity.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/BaseEntity.java deleted file mode 100644 index 09dc6e985052d47d66bbb8789d19b2b93690e317..0000000000000000000000000000000000000000 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/BaseEntity.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2002-2013 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.customers.support.jpa; - -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; - -/** - * Simple JavaBean domain object with an id property. Used as a base class for objects needing this property. - * - * @author Ken Krebs - * @author Juergen Hoeller - */ -@MappedSuperclass -public class BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - protected Integer id; - - - public void setId(Integer id) { - this.id = id; - } - - public Integer getId() { - return id; - } - - public boolean isNew() { - return (this.id == null); - } - -} diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/NamedEntity.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/NamedEntity.java deleted file mode 100644 index cf5b8218d74cf471a3b889f53bbcfb1454c4d9b3..0000000000000000000000000000000000000000 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/NamedEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2013 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.customers.support.jpa; - -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; - - -/** - * Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects - * needing these properties. - * - * @author Ken Krebs - * @author Juergen Hoeller - */ -@MappedSuperclass -public class NamedEntity extends BaseEntity { - - @Column(name = "name") - private String name; - - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - @Override - public String toString() { - return this.getName(); - } - -} diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/owner/OwnerResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java similarity index 92% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/owner/OwnerResource.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java index 665d01fd3467ec0bd1ce450f7881ba3da2905efd..1da650a4a90692a5dcb1b47cf6650ba259ceb455 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/owner/OwnerResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.customers.boundary.web.owner; +package org.springframework.samples.petclinic.customers.web; import lombok.RequiredArgsConstructor; @@ -23,8 +23,8 @@ import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.samples.petclinic.customers.domain.model.owner.Owner; -import org.springframework.samples.petclinic.customers.domain.model.owner.OwnerRepository; +import org.springframework.samples.petclinic.customers.model.Owner; +import org.springframework.samples.petclinic.customers.model.OwnerRepository; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetDetails.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java similarity index 73% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetDetails.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java index aa232d8c3a048d107d54f84500c0d9b2c448cfbf..f04d1eb124a0cfbd597d723d2fdb74167c22a45c 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetDetails.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java @@ -1,12 +1,12 @@ -package org.springframework.samples.petclinic.customers.boundary.web.pet; +package org.springframework.samples.petclinic.customers.web; import lombok.Data; import java.util.Date; import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.samples.petclinic.customers.domain.model.pet.Pet; -import org.springframework.samples.petclinic.customers.domain.model.pet.PetType; +import org.springframework.samples.petclinic.customers.model.Pet; +import org.springframework.samples.petclinic.customers.model.PetType; /** * @author mszarlinski@bravurasolutions.com on 2016-12-05. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetRequest.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java similarity index 84% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetRequest.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java index 149bba8c59536b4e2bf1192f75ba81100785af10..4e15ccdf35957eb3e63d961653661fe4d50f441e 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetRequest.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java @@ -1,4 +1,4 @@ -package org.springframework.samples.petclinic.customers.boundary.web.pet; +package org.springframework.samples.petclinic.customers.web; import lombok.Data; diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java similarity index 84% rename from spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetResource.java rename to spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java index fe3c11a859c41e521d3ff92ec9affc14cf204d54..aa007cbeb974a4ff41122cfb86cb3f01b8949ead 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.customers.boundary.web.pet; +package org.springframework.samples.petclinic.customers.web; import lombok.RequiredArgsConstructor; @@ -21,11 +21,11 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.samples.petclinic.customers.domain.model.owner.Owner; -import org.springframework.samples.petclinic.customers.domain.model.owner.OwnerRepository; -import org.springframework.samples.petclinic.customers.domain.model.pet.Pet; -import org.springframework.samples.petclinic.customers.domain.model.pet.PetRepository; -import org.springframework.samples.petclinic.customers.domain.model.pet.PetType; +import org.springframework.samples.petclinic.customers.model.Owner; +import org.springframework.samples.petclinic.customers.model.OwnerRepository; +import org.springframework.samples.petclinic.customers.model.Pet; +import org.springframework.samples.petclinic.customers.model.PetRepository; +import org.springframework.samples.petclinic.customers.model.PetType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; diff --git a/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/infrastructure/ValidatorTests.java b/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/infrastructure/ValidatorTests.java deleted file mode 100644 index 36d29774bdb24f21ab9e47f444086015ec0158b6..0000000000000000000000000000000000000000 --- a/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/infrastructure/ValidatorTests.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.springframework.samples.petclinic.customers.infrastructure; - -import org.junit.Test; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.samples.petclinic.customers.domain.model.Person; -import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; - -import javax.validation.ConstraintViolation; -import javax.validation.Validator; -import java.util.Locale; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Michael Isvy - * Simple test to make sure that Bean Validation is working - * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) - */ -public class ValidatorTests { - - private Validator createValidator() { - LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); - localValidatorFactoryBean.afterPropertiesSet(); - return localValidatorFactoryBean; - } - - @Test - public void shouldNotValidateWhenFirstNameEmpty() { - - LocaleContextHolder.setLocale(Locale.ENGLISH); - Person person = new Person(); - person.setFirstName(""); - person.setLastName("smith"); - - Validator validator = createValidator(); - Set<ConstraintViolation<Person>> constraintViolations = validator.validate(person); - - assertThat(constraintViolations.size()).isEqualTo(1); - ConstraintViolation<Person> violation = constraintViolations.iterator().next(); - assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName"); - assertThat(violation.getMessage()).isEqualTo("may not be empty"); - } - -} diff --git a/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetResourceTest.java b/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java similarity index 80% rename from spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetResourceTest.java rename to spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java index 107824a2cd80e2687419731f4d914f6eef41d2b6..7f152a673abca990cef3ab0d2bd991ee688ccd67 100644 --- a/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/boundary/web/pet/PetResourceTest.java +++ b/spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/web/PetResourceTest.java @@ -1,4 +1,4 @@ -package org.springframework.samples.petclinic.customers.boundary.web.pet; +package org.springframework.samples.petclinic.customers.web; import static org.mockito.BDDMockito.given; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -12,11 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; -import org.springframework.samples.petclinic.customers.domain.model.owner.Owner; -import org.springframework.samples.petclinic.customers.domain.model.owner.OwnerRepository; -import org.springframework.samples.petclinic.customers.domain.model.pet.Pet; -import org.springframework.samples.petclinic.customers.domain.model.pet.PetRepository; -import org.springframework.samples.petclinic.customers.domain.model.pet.PetType; +import org.springframework.samples.petclinic.customers.model.Owner; +import org.springframework.samples.petclinic.customers.model.OwnerRepository; +import org.springframework.samples.petclinic.customers.model.Pet; +import org.springframework.samples.petclinic.customers.model.PetRepository; +import org.springframework.samples.petclinic.customers.model.PetType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java index 0aab683ab1adc8ea7bbd869d12697ba7ced257a3..86cd4cc087ae166a47f11be02984dc9ae93f7705 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.samples.petclinic.vets.infrastructure.config.VetsProperties; +import org.springframework.samples.petclinic.vets.system.VetsProperties; /** * @author Maciej Szarlinski diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/shared/Person.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/shared/Person.java deleted file mode 100644 index f823162e6fc4fdcf4562c98d3b10dd0537ebb09d..0000000000000000000000000000000000000000 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/shared/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2002-2013 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.vets.domain.model.shared; - -import org.hibernate.validator.constraints.NotEmpty; -import org.springframework.samples.petclinic.vets.support.jpa.BaseEntity; - -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; - -/** - * Simple JavaBean domain object representing an person. - * - * @author Ken Krebs - */ -@MappedSuperclass -public class Person extends BaseEntity { - - @Column(name = "first_name") - @NotEmpty - protected String firstName; - - @Column(name = "last_name") - @NotEmpty - protected String lastName; - - public String getFirstName() { - return this.firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return this.lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - -} diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Specialty.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Specialty.java deleted file mode 100644 index ea2dd5901d67d2b0e8c1c3d0b1d601268d70617f..0000000000000000000000000000000000000000 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Specialty.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2002-2013 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.vets.domain.model.vet; - -import org.springframework.samples.petclinic.vets.support.jpa.NamedEntity; - -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * Models a {@link Vet Vet's} specialty (for example, dentistry). - * - * @author Juergen Hoeller - */ -@Entity -@Table(name = "specialties") -public class Specialty extends NamedEntity { - -} diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/BaseEntity.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java similarity index 63% rename from spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/BaseEntity.java rename to spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java index dfe71e81ec8221783afa74448303252146fe1318..f310e81a993dfc972bdbc81be092eef50b13065c 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/BaseEntity.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java @@ -13,36 +13,43 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.vets.support.jpa; +package org.springframework.samples.petclinic.vets.model; +import javax.persistence.Column; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.MappedSuperclass; +import javax.persistence.Table; /** - * Simple JavaBean domain object with an id property. Used as a base class for objects needing this property. + * Models a {@link Vet Vet's} specialty (for example, dentistry). * - * @author Ken Krebs * @author Juergen Hoeller */ -@MappedSuperclass -public class BaseEntity { +@Entity +@Table(name = "specialties") +public class Specialty { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - protected Integer id; + private Integer id; - - public void setId(Integer id) { - this.id = id; - } + @Column(name = "name") + private String name; public Integer getId() { return id; } - public boolean isNew() { - return (this.id == null); + public void setId(final Integer id) { + this.id = id; } + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } } diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Vet.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java similarity index 68% rename from spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Vet.java rename to spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java index 8d5d4ccbeb4bdbc38e7c2cb912a5369f534002db..830ab06160706b7df9d69f9cd8271fe3a6d59d2e 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Vet.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.vets.domain.model.vet; +package org.springframework.samples.petclinic.vets.model; import java.util.ArrayList; import java.util.Collections; @@ -21,17 +21,21 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; import javax.xml.bind.annotation.XmlElement; +import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.PropertyComparator; -import org.springframework.samples.petclinic.vets.domain.model.shared.Person; /** * Simple JavaBean domain object representing a veterinarian. @@ -44,13 +48,49 @@ import org.springframework.samples.petclinic.vets.domain.model.shared.Person; */ @Entity @Table(name = "vets") -public class Vet extends Person { +public class Vet { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "first_name") + @NotEmpty + private String firstName; + + @Column(name = "last_name") + @NotEmpty + private String lastName; @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), - inverseJoinColumns = @JoinColumn(name = "specialty_id")) + inverseJoinColumns = @JoinColumn(name = "specialty_id")) private Set<Specialty> specialties; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFirstName() { + return this.firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return this.lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + protected Set<Specialty> getSpecialtiesInternal() { if (this.specialties == null) { this.specialties = new HashSet<>(); diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/VetRepository.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java similarity index 94% rename from spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/VetRepository.java rename to spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java index 7258dc8a7dadbaf0e2ee201d82c31940051dd713..01c35d0b6e38fe08e474d4d33b925d45f80fc523 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/VetRepository.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.vets.domain.model.vet; +package org.springframework.samples.petclinic.vets.model; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/NamedEntity.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/NamedEntity.java deleted file mode 100644 index 7733f61f261d327163d723c5ed366be1646a9a08..0000000000000000000000000000000000000000 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/NamedEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2013 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.vets.support.jpa; - -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; - - -/** - * Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects - * needing these properties. - * - * @author Ken Krebs - * @author Juergen Hoeller - */ -@MappedSuperclass -public class NamedEntity extends BaseEntity { - - @Column(name = "name") - private String name; - - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - @Override - public String toString() { - return this.getName(); - } - -} diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/infrastructure/config/CacheConfig.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java similarity index 95% rename from spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/infrastructure/config/CacheConfig.java rename to spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java index 0d36eb9d67caa1bec8d685f636335ad8a29a95ce..3e88b4fbfd47bb032df2e4c3b900124e470b527c 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/infrastructure/config/CacheConfig.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java @@ -1,4 +1,4 @@ -package org.springframework.samples.petclinic.vets.infrastructure.config; +package org.springframework.samples.petclinic.vets.system; import org.ehcache.config.CacheConfiguration; import org.ehcache.config.builders.CacheConfigurationBuilder; diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/infrastructure/config/VetsProperties.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java similarity index 83% rename from spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/infrastructure/config/VetsProperties.java rename to spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java index 33df8f8f92ee448c49ac1e84df5fabc6438d8fe9..1169114a8336e0d4ee1f6e48dfbcbda9c95eb279 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/infrastructure/config/VetsProperties.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java @@ -1,4 +1,4 @@ -package org.springframework.samples.petclinic.vets.infrastructure.config; +package org.springframework.samples.petclinic.vets.system; import lombok.Data; diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/boundary/VetResource.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java similarity index 85% rename from spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/boundary/VetResource.java rename to spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java index d27f1b3b0eb441d7d1cc864e9c1d5fe189582e32..52540d4cb32f1eb8f548d48d0c1652f8080f253c 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/boundary/VetResource.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.vets.web.boundary; +package org.springframework.samples.petclinic.vets.web; import lombok.RequiredArgsConstructor; import java.util.List; -import org.springframework.samples.petclinic.vets.domain.model.vet.Vet; -import org.springframework.samples.petclinic.vets.domain.model.vet.VetRepository; +import org.springframework.samples.petclinic.vets.model.Vet; +import org.springframework.samples.petclinic.vets.model.VetRepository; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/boundary/VetResourceTest.java b/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java similarity index 86% rename from spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/boundary/VetResourceTest.java rename to spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java index aa3bc5777479c5e7d6ff5b57a0c18003bf32c606..b4c555f17f57129f6426786addd7fb61b0c92d4e 100644 --- a/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/boundary/VetResourceTest.java +++ b/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java @@ -1,4 +1,4 @@ -package org.springframework.samples.petclinic.vets.web.boundary; +package org.springframework.samples.petclinic.vets.web; import static java.util.Arrays.asList; import static org.mockito.BDDMockito.given; @@ -12,8 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; -import org.springframework.samples.petclinic.vets.domain.model.vet.Vet; -import org.springframework.samples.petclinic.vets.domain.model.vet.VetRepository; +import org.springframework.samples.petclinic.vets.model.Vet; +import org.springframework.samples.petclinic.vets.model.VetRepository; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/application/VisitService.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/application/VisitService.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/shared/Person.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/shared/Person.java deleted file mode 100644 index a59ff78ae0de9fe1f8ec74cdad7216ab1648c307..0000000000000000000000000000000000000000 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/shared/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2002-2013 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.visits.domain.shared; - -import org.hibernate.validator.constraints.NotEmpty; -import org.springframework.samples.petclinic.visits.support.jpa.BaseEntity; - -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; - -/** - * Simple JavaBean domain object representing an person. - * - * @author Ken Krebs - */ -@MappedSuperclass -public class Person extends BaseEntity { - - @Column(name = "first_name") - @NotEmpty - protected String firstName; - - @Column(name = "last_name") - @NotEmpty - protected String lastName; - - public String getFirstName() { - return this.firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return this.lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - -} diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/model/visit/Visit.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java similarity index 59% rename from spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/model/visit/Visit.java rename to spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java index 1d7dedc283a59fe5f1cda0c0c898fcc5222d882c..7aaa63a9f933171f0105a017251b8ef00fa41085 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/model/visit/Visit.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java @@ -13,14 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.visits.domain.model.visit; +package org.springframework.samples.petclinic.visits.model; -import com.fasterxml.jackson.annotation.JsonFormat; -import org.springframework.samples.petclinic.visits.support.jpa.BaseEntity; +import java.util.Date; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import javax.validation.constraints.Size; -import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; /** * Simple JavaBean domain object representing a visit. @@ -30,65 +37,36 @@ import java.util.Date; */ @Entity @Table(name = "visits") -public class Visit extends BaseEntity { +public class Visit { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; - /** - * Holds value of property date. - */ @Column(name = "visit_date") @Temporal(TemporalType.TIMESTAMP) @JsonFormat(pattern = "yyyy-MM-dd") private Date date = new Date(); - /** - * Holds value of property description. - */ @Size(max = 8192) @Column(name = "description") private String description; - /** - * Holds id of property pet. - */ @Column(name = "pet_id") private int petId; - /** - * Getter for property date. - * - * @return Value of property date. - */ - public Date getDate() { - return date; + public Integer getId() { + return id; } - /** - * Setter for property date. - * - * @param date New value of property date. - */ - public void setDate(Date date) { - this.date = date; + public Date getDate() { + return date; } - /** - * Getter for property description. - * - * @return Value of property description. - */ public String getDescription() { return description; } - /** - * Setter for property description. - * - * @param description New value of property description. - */ - public void setDescription(String description) { - this.description = description; - } - public int getPetId() { return petId; } diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/model/visit/VisitRepository.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java similarity index 94% rename from spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/model/visit/VisitRepository.java rename to spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java index 5c0580570cf13b42fb2f7461d82ca2fcb5d112c0..f3ed33d7c7c27c843aad784558ed90fdfc7e653e 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/model/visit/VisitRepository.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.visits.domain.model.visit; +package org.springframework.samples.petclinic.visits.model; import java.util.List; diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/NamedEntity.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/NamedEntity.java deleted file mode 100644 index 33e980c458a658004a9897de9a694707d537899c..0000000000000000000000000000000000000000 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/NamedEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2013 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.visits.support.jpa; - -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; - - -/** - * Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects - * needing these properties. - * - * @author Ken Krebs - * @author Juergen Hoeller - */ -@MappedSuperclass -public class NamedEntity extends BaseEntity { - - @Column(name = "name") - private String name; - - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - @Override - public String toString() { - return this.getName(); - } - -} diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/boundary/web/VisitResource.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java similarity index 89% rename from spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/boundary/web/VisitResource.java rename to spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java index 018dd1309ddb21e06d0103a2a0a6059438353d13..28b8850815be3008e18ebefb0163b78ece0245da 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/boundary/web/VisitResource.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.samples.petclinic.visits.boundary.web; +package org.springframework.samples.petclinic.visits.web; import lombok.RequiredArgsConstructor; @@ -23,8 +23,8 @@ import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.samples.petclinic.visits.domain.model.visit.Visit; -import org.springframework.samples.petclinic.visits.domain.model.visit.VisitRepository; +import org.springframework.samples.petclinic.visits.model.Visit; +import org.springframework.samples.petclinic.visits.model.VisitRepository; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping;