Adicionado campo para email

This commit is contained in:
CONRADO SANTOS BOEIRA 2019-11-18 13:45:54 -02:00
parent 32301ed531
commit 3c83e6bf1d
10 changed files with 51 additions and 22 deletions

View file

@ -58,6 +58,11 @@ public class Owner extends Person {
@Digits(fraction = 0, integer = 10) @Digits(fraction = 0, integer = 10)
private String telephone; private String telephone;
@Column(name = "email")
@NotEmpty
private String email;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets; private Set<Pet> pets;
@ -85,6 +90,15 @@ public class Owner extends Person {
this.telephone = telephone; this.telephone = telephone;
} }
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
protected Set<Pet> getPetsInternal() { protected Set<Pet> getPetsInternal() {
if (this.pets == null) { if (this.pets == null) {
this.pets = new HashSet<>(); this.pets = new HashSet<>();
@ -147,6 +161,7 @@ public class Owner extends Person {
.append("id", this.getId()).append("new", this.isNew()) .append("id", this.getId()).append("new", this.isNew())
.append("lastName", this.getLastName()) .append("lastName", this.getLastName())
.append("firstName", this.getFirstName()).append("address", this.address) .append("firstName", this.getFirstName()).append("address", this.address)
.append("city", this.city).append("telephone", this.telephone).toString(); .append("city", this.city).append("telephone", this.telephone)
.append("email", this.email).toString();
} }
} }

View file

@ -22,16 +22,16 @@ INSERT INTO types VALUES (4, 'snake');
INSERT INTO types VALUES (5, 'bird'); INSERT INTO types VALUES (5, 'bird');
INSERT INTO types VALUES (6, 'hamster'); INSERT INTO types VALUES (6, 'hamster');
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023', 'george@email.com');
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749', 'betty@email.com');
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763', 'eduardo@email.com');
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198', 'harold@email.com');
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765', 'peter@email.com');
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654', 'jean@email.com');
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387', 'jeff@email.com');
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683', 'maria@email.com');
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435', 'david@email.com');
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487', 'carlos@email.com');
INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1); INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1);
INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2); INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2);

View file

@ -39,7 +39,8 @@ CREATE TABLE owners (
last_name VARCHAR_IGNORECASE(30), last_name VARCHAR_IGNORECASE(30),
address VARCHAR(255), address VARCHAR(255),
city VARCHAR(80), city VARCHAR(80),
telephone VARCHAR(20) telephone VARCHAR(20),
email VARCHAR(100)
); );
CREATE INDEX owners_last_name ON owners (last_name); CREATE INDEX owners_last_name ON owners (last_name);

View file

@ -22,16 +22,16 @@ INSERT IGNORE INTO types VALUES (4, 'snake');
INSERT IGNORE INTO types VALUES (5, 'bird'); INSERT IGNORE INTO types VALUES (5, 'bird');
INSERT IGNORE INTO types VALUES (6, 'hamster'); INSERT IGNORE INTO types VALUES (6, 'hamster');
INSERT IGNORE INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); INSERT IGNORE INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023', 'george@email.com');
INSERT IGNORE INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); INSERT IGNORE INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749', 'betty@email.com');
INSERT IGNORE INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); INSERT IGNORE INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763', 'eduardo@email.com');
INSERT IGNORE INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); INSERT IGNORE INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198', 'harold@email.com');
INSERT IGNORE INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); INSERT IGNORE INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765', 'peter@email.com');
INSERT IGNORE INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); INSERT IGNORE INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654', 'jean@email.com');
INSERT IGNORE INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); INSERT IGNORE INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387', 'jeff@email.com');
INSERT IGNORE INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); INSERT IGNORE INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683', 'maria@email.com');
INSERT IGNORE INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); INSERT IGNORE INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435', 'david@email.com');
INSERT IGNORE INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); INSERT IGNORE INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487', 'carlos@email.com');
INSERT IGNORE INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1); INSERT IGNORE INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1);
INSERT IGNORE INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2); INSERT IGNORE INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);

View file

@ -42,6 +42,7 @@ CREATE TABLE IF NOT EXISTS owners (
address VARCHAR(255), address VARCHAR(255),
city VARCHAR(80), city VARCHAR(80),
telephone VARCHAR(20), telephone VARCHAR(20),
email VARCHAR(100),
INDEX(last_name) INDEX(last_name)
) engine=InnoDB; ) engine=InnoDB;

View file

@ -16,6 +16,8 @@
th:replace="~{fragments/inputField :: input ('City', 'city', 'text')}" /> th:replace="~{fragments/inputField :: input ('City', 'city', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Telephone', 'telephone', 'text')}" /> th:replace="~{fragments/inputField :: input ('Telephone', 'telephone', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Email', 'email', 'text')}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">

View file

@ -26,6 +26,10 @@
<th>Telephone</th> <th>Telephone</th>
<td th:text="*{telephone}" /></td> <td th:text="*{telephone}" /></td>
</tr> </tr>
<tr>
<th>Email</th>
<td th:text="*{email}" /></td>
</tr>
</table> </table>
<a th:href="@{{id}/edit(id=${owner.id})}" class="btn btn-default">Edit <a th:href="@{{id}/edit(id=${owner.id})}" class="btn btn-default">Edit

View file

@ -13,6 +13,7 @@
<th style="width: 200px;">Address</th> <th style="width: 200px;">Address</th>
<th>City</th> <th>City</th>
<th style="width: 120px">Telephone</th> <th style="width: 120px">Telephone</th>
<th style="width: 120px">Email</th>
<th>Pets</th> <th>Pets</th>
</tr> </tr>
</thead> </thead>
@ -24,6 +25,7 @@
<td th:text="${owner.address}"/> <td th:text="${owner.address}"/>
<td th:text="${owner.city}"/> <td th:text="${owner.city}"/>
<td th:text="${owner.telephone}"/> <td th:text="${owner.telephone}"/>
<td th:text="${owner.email}"/>
<td><span th:each="pet : ${owner.pets}" th:text="${pet.name} "/></td> <td><span th:each="pet : ${owner.pets}" th:text="${pet.name} "/></td>
</tr> </tr>
</tbody> </tbody>

View file

@ -73,6 +73,7 @@ class OwnerControllerTests {
george.setAddress("110 W. Liberty St."); george.setAddress("110 W. Liberty St.");
george.setCity("Madison"); george.setCity("Madison");
george.setTelephone("6085551023"); george.setTelephone("6085551023");
george.setEmail("george@email.com");
Pet max = new Pet(); Pet max = new Pet();
PetType dog = new PetType(); PetType dog = new PetType();
dog.setName("dog"); dog.setName("dog");
@ -103,6 +104,7 @@ class OwnerControllerTests {
.param("address", "123 Caramel Street") .param("address", "123 Caramel Street")
.param("city", "London") .param("city", "London")
.param("telephone", "01316761638") .param("telephone", "01316761638")
.param("email", "joe@email.com")
) )
.andExpect(status().is3xxRedirection()); .andExpect(status().is3xxRedirection());
} }
@ -179,6 +181,7 @@ class OwnerControllerTests {
.param("address", "123 Caramel Street") .param("address", "123 Caramel Street")
.param("city", "London") .param("city", "London")
.param("telephone", "01616291589") .param("telephone", "01616291589")
.param("email", "joe@email.com")
) )
.andExpect(status().is3xxRedirection()) .andExpect(status().is3xxRedirection())
.andExpect(view().name("redirect:/owners/{ownerId}")); .andExpect(view().name("redirect:/owners/{ownerId}"));

View file

@ -102,6 +102,7 @@ class ClinicServiceTests {
owner.setAddress("4, Evans Street"); owner.setAddress("4, Evans Street");
owner.setCity("Wollongong"); owner.setCity("Wollongong");
owner.setTelephone("4444444444"); owner.setTelephone("4444444444");
owner.setEmail("sam@email.com");
this.owners.save(owner); this.owners.save(owner);
assertThat(owner.getId().longValue()).isNotEqualTo(0); assertThat(owner.getId().longValue()).isNotEqualTo(0);