Skip to content

Commit ed116de

Browse files
author
michaelisvy
committed
Merge pull request #2 from gordonad/master
Build and logging improvements
2 parents cec8110 + 2ab9422 commit ed116de

File tree

90 files changed

+3511
-3117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3511
-3117
lines changed

pom.xml

Lines changed: 949 additions & 305 deletions
Large diffs are not rendered by default.

src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@
2121
import javax.persistence.MappedSuperclass;
2222

2323
/**
24-
* Simple JavaBean domain object with an id property.
25-
* Used as a base class for objects needing this property.
24+
* Simple JavaBean domain object with an id property. Used as a base class for objects needing this property.
2625
*
2726
* @author Ken Krebs
2827
* @author Juergen Hoeller
2928
*/
3029
@MappedSuperclass
3130
public class BaseEntity {
32-
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
33-
protected Integer id;
34-
31+
@Id
32+
@GeneratedValue(strategy = GenerationType.IDENTITY)
33+
protected Integer id;
3534

36-
public void setId(Integer id) {
37-
this.id = id;
38-
}
3935

40-
public Integer getId() {
41-
return id;
42-
}
36+
public void setId(Integer id) {
37+
this.id = id;
38+
}
4339

44-
public boolean isNew() {
45-
return (this.id == null);
46-
}
40+
public Integer getId() {
41+
return id;
42+
}
43+
44+
public boolean isNew() {
45+
return (this.id == null);
46+
}
4747

4848
}

src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@
2020

2121

2222
/**
23-
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>.
24-
* Used as a base class for objects needing these properties.
23+
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects
24+
* needing these properties.
2525
*
2626
* @author Ken Krebs
2727
* @author Juergen Hoeller
2828
*/
2929
@MappedSuperclass
3030
public class NamedEntity extends BaseEntity {
3131

32-
@Column(name="name")
33-
private String name;
34-
32+
@Column(name = "name")
33+
private String name;
3534

36-
public void setName(String name) {
37-
this.name = name;
38-
}
3935

40-
public String getName() {
41-
return this.name;
42-
}
36+
public void setName(String name) {
37+
this.name = name;
38+
}
4339

44-
@Override
45-
public String toString() {
46-
return this.getName();
47-
}
40+
public String getName() {
41+
return this.name;
42+
}
43+
44+
@Override
45+
public String toString() {
46+
return this.getName();
47+
}
4848

4949
}

src/main/java/org/springframework/samples/petclinic/model/Owner.java

Lines changed: 112 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,15 @@
1515
*/
1616
package org.springframework.samples.petclinic.model;
1717

18-
import java.util.ArrayList;
19-
import java.util.Collections;
20-
import java.util.HashSet;
21-
import java.util.List;
22-
import java.util.Set;
23-
24-
import javax.persistence.CascadeType;
25-
import javax.persistence.Column;
26-
import javax.persistence.Entity;
27-
import javax.persistence.OneToMany;
28-
import javax.persistence.Table;
29-
import javax.validation.constraints.Digits;
30-
3118
import org.hibernate.validator.constraints.NotEmpty;
3219
import org.springframework.beans.support.MutableSortDefinition;
3320
import org.springframework.beans.support.PropertyComparator;
3421
import org.springframework.core.style.ToStringCreator;
3522

23+
import javax.persistence.*;
24+
import javax.validation.constraints.Digits;
25+
import java.util.*;
26+
3627
/**
3728
* Simple JavaBean domain object representing an owner.
3829
*
@@ -41,111 +32,113 @@
4132
* @author Sam Brannen
4233
* @author Michael Isvy
4334
*/
44-
@Entity @Table(name="owners")
35+
@Entity
36+
@Table(name = "owners")
4537
public class Owner extends Person {
46-
@Column(name="address")
47-
@NotEmpty
48-
private String address;
49-
50-
@Column(name="city")
51-
@NotEmpty
52-
private String city;
53-
54-
@Column(name="telephone")
55-
@NotEmpty @Digits(fraction = 0, integer = 10)
56-
private String telephone;
57-
58-
@OneToMany(cascade=CascadeType.ALL, mappedBy="owner")
59-
private Set<Pet> pets;
60-
61-
62-
public String getAddress() {
63-
return this.address;
64-
}
65-
66-
public void setAddress(String address) {
67-
this.address = address;
68-
}
69-
70-
public String getCity() {
71-
return this.city;
72-
}
73-
74-
public void setCity(String city) {
75-
this.city = city;
76-
}
77-
78-
public String getTelephone() {
79-
return this.telephone;
80-
}
81-
82-
public void setTelephone(String telephone) {
83-
this.telephone = telephone;
84-
}
85-
86-
protected void setPetsInternal(Set<Pet> pets) {
87-
this.pets = pets;
88-
}
89-
90-
protected Set<Pet> getPetsInternal() {
91-
if (this.pets == null) {
92-
this.pets = new HashSet<Pet>();
93-
}
94-
return this.pets;
95-
}
96-
97-
public List<Pet> getPets() {
98-
List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal());
99-
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
100-
return Collections.unmodifiableList(sortedPets);
101-
}
102-
103-
public void addPet(Pet pet) {
104-
getPetsInternal().add(pet);
105-
pet.setOwner(this);
106-
}
107-
108-
/**
109-
* Return the Pet with the given name, or null if none found for this Owner.
110-
*
111-
* @param name to test
112-
* @return true if pet name is already in use
113-
*/
114-
public Pet getPet(String name) {
115-
return getPet(name, false);
116-
}
117-
118-
/**
119-
* Return the Pet with the given name, or null if none found for this Owner.
120-
*
121-
* @param name to test
122-
* @return true if pet name is already in use
123-
*/
124-
public Pet getPet(String name, boolean ignoreNew) {
125-
name = name.toLowerCase();
126-
for (Pet pet : getPetsInternal()) {
127-
if (!ignoreNew || !pet.isNew()) {
128-
String compName = pet.getName();
129-
compName = compName.toLowerCase();
130-
if (compName.equals(name)) {
131-
return pet;
132-
}
133-
}
134-
}
135-
return null;
136-
}
137-
138-
@Override
139-
public String toString() {
140-
return new ToStringCreator(this)
141-
142-
.append("id", this.getId())
143-
.append("new", this.isNew())
144-
.append("lastName", this.getLastName())
145-
.append("firstName", this.getFirstName())
146-
.append("address", this.address)
147-
.append("city", this.city)
148-
.append("telephone", this.telephone)
149-
.toString();
150-
}
38+
@Column(name = "address")
39+
@NotEmpty
40+
private String address;
41+
42+
@Column(name = "city")
43+
@NotEmpty
44+
private String city;
45+
46+
@Column(name = "telephone")
47+
@NotEmpty
48+
@Digits(fraction = 0, integer = 10)
49+
private String telephone;
50+
51+
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
52+
private Set<Pet> pets;
53+
54+
55+
public String getAddress() {
56+
return this.address;
57+
}
58+
59+
public void setAddress(String address) {
60+
this.address = address;
61+
}
62+
63+
public String getCity() {
64+
return this.city;
65+
}
66+
67+
public void setCity(String city) {
68+
this.city = city;
69+
}
70+
71+
public String getTelephone() {
72+
return this.telephone;
73+
}
74+
75+
public void setTelephone(String telephone) {
76+
this.telephone = telephone;
77+
}
78+
79+
protected void setPetsInternal(Set<Pet> pets) {
80+
this.pets = pets;
81+
}
82+
83+
protected Set<Pet> getPetsInternal() {
84+
if (this.pets == null) {
85+
this.pets = new HashSet<Pet>();
86+
}
87+
return this.pets;
88+
}
89+
90+
public List<Pet> getPets() {
91+
List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal());
92+
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
93+
return Collections.unmodifiableList(sortedPets);
94+
}
95+
96+
public void addPet(Pet pet) {
97+
getPetsInternal().add(pet);
98+
pet.setOwner(this);
99+
}
100+
101+
/**
102+
* Return the Pet with the given name, or null if none found for this Owner.
103+
*
104+
* @param name to test
105+
* @return true if pet name is already in use
106+
*/
107+
public Pet getPet(String name) {
108+
return getPet(name, false);
109+
}
110+
111+
/**
112+
* Return the Pet with the given name, or null if none found for this Owner.
113+
*
114+
* @param name to test
115+
* @return true if pet name is already in use
116+
*/
117+
public Pet getPet(String name, boolean ignoreNew) {
118+
name = name.toLowerCase();
119+
for (Pet pet : getPetsInternal()) {
120+
if (!ignoreNew || !pet.isNew()) {
121+
String compName = pet.getName();
122+
compName = compName.toLowerCase();
123+
if (compName.equals(name)) {
124+
return pet;
125+
}
126+
}
127+
}
128+
return null;
129+
}
130+
131+
@Override
132+
public String toString() {
133+
return new ToStringCreator(this)
134+
135+
.append("id", this.getId())
136+
.append("new", this.isNew())
137+
.append("lastName", this.getLastName())
138+
.append("firstName", this.getFirstName())
139+
.append("address", this.address)
140+
.append("city", this.city)
141+
.append("telephone", this.telephone)
142+
.toString();
143+
}
151144
}

0 commit comments

Comments
 (0)