Added Doctor Address

Yung Money
This commit is contained in:
Daniel.ryan@glowtouch.com 2017-06-19 15:56:36 -04:00
parent e7238582ff
commit c68507bdc4
4 changed files with 54 additions and 7 deletions

View file

@ -21,6 +21,7 @@ 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.JoinColumn;
@ -29,6 +30,7 @@ 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.kidclinic.model.Person;
@ -48,6 +50,18 @@ public class Doctor extends Person {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "doctor_specialties", joinColumns = @JoinColumn(name = "doctor_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
private Set<Specialty> specialties;
@Column(name = "address")
@NotEmpty
private String address;
@Column(name = "city")
@NotEmpty
private String city;
@Column(name = "state")
@NotEmpty
private String state;
protected Set<Specialty> getSpecialtiesInternal() {
if (this.specialties == null) {
@ -75,5 +89,29 @@ public class Doctor extends Person {
public void addSpecialty(Specialty specialty) {
getSpecialtiesInternal().add(specialty);
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getState(){
return this.state;
}
public void setState(String state){
this.state = state;
}
}

View file

@ -1,9 +1,9 @@
INSERT INTO doctors VALUES (1, 'James', 'Carter');
INSERT INTO doctors VALUES (2, 'Helen', 'Leary');
INSERT INTO doctors VALUES (3, 'Linda', 'Douglas');
INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega');
INSERT INTO doctors VALUES (5, 'Henry', 'Stevens');
INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins');
INSERT INTO doctors VALUES (1, 'James', 'Carter', '3424 University Ave.', 'Madison', 'WI');
INSERT INTO doctors VALUES (2, 'Helen', 'Leary', '750 Hilldale Way', 'Madison', 'WI');
INSERT INTO doctors VALUES (3, 'Linda', 'Douglas', '6136 University Ave.', 'Middleton', 'WI');
INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega', '8300 Airport Rd.', 'Middleton', 'WI');
INSERT INTO doctors VALUES (5, 'Henry', 'Stevens', '876 Jupiter Dr.', 'Madison', 'WI');
INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins', '4905 Monona Dr.', 'Monona', 'WI');
INSERT INTO specialties VALUES (1, 'radiology');
INSERT INTO specialties VALUES (2, 'surgery');

View file

@ -10,7 +10,10 @@ DROP TABLE parents IF EXISTS;
CREATE TABLE doctors (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)
last_name VARCHAR(30),
address VARCHAR(255),
city VARCHAR(80),
state VARCHAR(80)
);
CREATE INDEX doctors_last_name ON doctors (last_name);

View file

@ -11,12 +11,18 @@
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Specialties</th>
</tr>
</thead>
<tbody>
<tr th:each="doctor : ${doctors.doctorList}">
<td th:text="${doctor.firstName + ' ' + doctor.lastName}"></td>
<td th:text="${doctor.address}"></td>
<td th:text="${doctor.city}"></td>
<td th:text="${doctor.state}"></td>
<td><span th:each="specialty : ${doctor.specialties}"
th:text="${specialty.name + ' '}" /> <span
th:if="${doctor.nrOfSpecialties == 0}">none</span></td>