From 769c22935a343f06836846e5677c1b58d685296f Mon Sep 17 00:00:00 2001 From: Maciej Szarlinski <mszarlinski@gmail.com> Date: Thu, 8 Dec 2016 09:44:46 +0100 Subject: [PATCH] Flatten package structure, removed Person, NamedEntity and BaseEntity super classes --- .../customers/application/OwnerService.java | 0 .../customers/application/PetService.java | 0 .../customers/domain/model/Person.java | 58 ----------------- .../customers/domain/model/pet/PetType.java | 31 --------- .../{domain/model/owner => model}/Owner.java | 43 +++++++++++-- .../owner => model}/OwnerRepository.java | 2 +- .../{domain/model/pet => model}/Pet.java | 56 ++++++++++++---- .../model/pet => model}/PetRepository.java | 2 +- .../petclinic/customers/model/PetType.java | 30 +++++---- .../customers/support/jpa/BaseEntity.java | 48 -------------- .../customers/support/jpa/NamedEntity.java | 49 -------------- .../web/owner => web}/OwnerResource.java | 6 +- .../{boundary/web/pet => web}/PetDetails.java | 6 +- .../{boundary/web/pet => web}/PetRequest.java | 2 +- .../web/pet => web}/PetResource.java | 12 ++-- .../infrastructure/ValidatorTests.java | 45 ------------- .../web/pet => web}/PetResourceTest.java | 12 ++-- .../vets/VetsServiceApplication.java | 2 +- .../vets/domain/model/shared/Person.java | 57 ----------------- .../vets/domain/model/vet/Specialty.java | 32 ---------- .../BaseEntity.java => model/Specialty.java} | 33 ++++++---- .../vets/{domain/model/vet => model}/Vet.java | 48 ++++++++++++-- .../model/vet => model}/VetRepository.java | 2 +- .../vets/support/jpa/NamedEntity.java | 49 -------------- .../config => system}/CacheConfig.java | 2 +- .../config => system}/VetsProperties.java | 2 +- .../vets/web/{boundary => }/VetResource.java | 6 +- .../web/{boundary => }/VetResourceTest.java | 6 +- .../visits/application/VisitService.java | 0 .../visits/domain/shared/Person.java | 57 ----------------- .../{domain/model/visit => model}/Visit.java | 64 ++++++------------- .../visit => model}/VisitRepository.java | 2 +- .../visits/support/jpa/NamedEntity.java | 49 -------------- .../{boundary => }/web/VisitResource.java | 6 +- 34 files changed, 217 insertions(+), 602 deletions(-) delete mode 100644 spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/application/OwnerService.java delete mode 100644 spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/application/PetService.java delete mode 100644 spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/Person.java delete mode 100644 spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/domain/model/pet/PetType.java rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{domain/model/owner => model}/Owner.java (79%) rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{domain/model/owner => model}/OwnerRepository.java (94%) rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{domain/model/pet => model}/Pet.java (59%) rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{domain/model/pet => model}/PetRepository.java (95%) rename spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/BaseEntity.java => spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java (68%) delete mode 100644 spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/BaseEntity.java delete mode 100644 spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/support/jpa/NamedEntity.java rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{boundary/web/owner => web}/OwnerResource.java (92%) rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{boundary/web/pet => web}/PetDetails.java (73%) rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{boundary/web/pet => web}/PetRequest.java (84%) rename spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/{boundary/web/pet => web}/PetResource.java (84%) delete mode 100644 spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/infrastructure/ValidatorTests.java rename spring-petclinic-customers-service/src/test/java/org/springframework/samples/petclinic/customers/{boundary/web/pet => web}/PetResourceTest.java (80%) delete mode 100644 spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/shared/Person.java delete mode 100644 spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/domain/model/vet/Specialty.java rename spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/{support/jpa/BaseEntity.java => model/Specialty.java} (63%) rename spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/{domain/model/vet => model}/Vet.java (68%) rename spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/{domain/model/vet => model}/VetRepository.java (94%) delete mode 100644 spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/support/jpa/NamedEntity.java rename spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/{infrastructure/config => system}/CacheConfig.java (95%) rename spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/{infrastructure/config => system}/VetsProperties.java (83%) rename spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/{boundary => }/VetResource.java (85%) rename spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/{boundary => }/VetResourceTest.java (86%) delete mode 100644 spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/application/VisitService.java delete mode 100644 spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/domain/shared/Person.java rename spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/{domain/model/visit => model}/Visit.java (59%) rename spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/{domain/model/visit => model}/VisitRepository.java (94%) delete mode 100644 spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/support/jpa/NamedEntity.java rename spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/{boundary => }/web/VisitResource.java (89%) 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 e69de29b..00000000 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 e69de29b..00000000 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 b17ed0fa..00000000 --- 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 59065f5e..00000000 --- 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 a9ad0196..49fc96ea 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 006fe317..73aad511 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 13be6e18..625ff737 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 06350a46..4473853e 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 c59a4384..20743901 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 09dc6e98..00000000 --- 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 cf5b8218..00000000 --- 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 665d01fd..1da650a4 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 aa232d8c..f04d1eb1 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 149bba8c..4e15ccdf 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 fe3c11a8..aa007cbe 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 36d29774..00000000 --- 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 107824a2..7f152a67 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 0aab683a..86cd4cc0 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 f823162e..00000000 --- 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 ea2dd590..00000000 --- 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 dfe71e81..f310e81a 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 8d5d4ccb..830ab061 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 7258dc8a..01c35d0b 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 7733f61f..00000000 --- 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 0d36eb9d..3e88b4fb 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 33df8f8f..1169114a 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 d27f1b3b..52540d4c 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 aa3bc577..b4c555f1 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 e69de29b..00000000 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 a59ff78a..00000000 --- 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 1d7dedc2..7aaa63a9 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 5c058057..f3ed33d7 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 33e980c4..00000000 --- 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 018dd130..28b88508 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; -- GitLab