mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:35:49 +00:00
#87 Petclinic should be compatible with Java 7 for the time being
This commit is contained in:
parent
80ff54ac03
commit
8b625617cb
8 changed files with 14 additions and 14 deletions
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<!-- Generic properties -->
|
<!-- Generic properties -->
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.7</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
|
|
|
@ -91,13 +91,13 @@ public class Owner extends Person {
|
||||||
|
|
||||||
protected Set<Pet> getPetsInternal() {
|
protected Set<Pet> getPetsInternal() {
|
||||||
if (this.pets == null) {
|
if (this.pets == null) {
|
||||||
this.pets = new HashSet<Pet>();
|
this.pets = new HashSet<>();
|
||||||
}
|
}
|
||||||
return this.pets;
|
return this.pets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Pet> getPets() {
|
public List<Pet> getPets() {
|
||||||
List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal());
|
List<Pet> sortedPets = new ArrayList<>(getPetsInternal());
|
||||||
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
|
PropertyComparator.sort(sortedPets, new MutableSortDefinition("name", true, true));
|
||||||
return Collections.unmodifiableList(sortedPets);
|
return Collections.unmodifiableList(sortedPets);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,13 +94,13 @@ public class Pet extends NamedEntity {
|
||||||
|
|
||||||
protected Set<Visit> getVisitsInternal() {
|
protected Set<Visit> getVisitsInternal() {
|
||||||
if (this.visits == null) {
|
if (this.visits == null) {
|
||||||
this.visits = new HashSet<Visit>();
|
this.visits = new HashSet<>();
|
||||||
}
|
}
|
||||||
return this.visits;
|
return this.visits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Visit> getVisits() {
|
public List<Visit> getVisits() {
|
||||||
List<Visit> sortedVisits = new ArrayList<Visit>(getVisitsInternal());
|
List<Visit> sortedVisits = new ArrayList<>(getVisitsInternal());
|
||||||
PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false));
|
PropertyComparator.sort(sortedVisits, new MutableSortDefinition("date", false, false));
|
||||||
return Collections.unmodifiableList(sortedVisits);
|
return Collections.unmodifiableList(sortedVisits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,14 +56,14 @@ public class Vet extends Person {
|
||||||
|
|
||||||
protected Set<Specialty> getSpecialtiesInternal() {
|
protected Set<Specialty> getSpecialtiesInternal() {
|
||||||
if (this.specialties == null) {
|
if (this.specialties == null) {
|
||||||
this.specialties = new HashSet<Specialty>();
|
this.specialties = new HashSet<>();
|
||||||
}
|
}
|
||||||
return this.specialties;
|
return this.specialties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public List<Specialty> getSpecialties() {
|
public List<Specialty> getSpecialties() {
|
||||||
List<Specialty> sortedSpecs = new ArrayList<Specialty>(getSpecialtiesInternal());
|
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
|
||||||
PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true, true));
|
PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true, true));
|
||||||
return Collections.unmodifiableList(sortedSpecs);
|
return Collections.unmodifiableList(sortedSpecs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class Vets {
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public List<Vet> getVetList() {
|
public List<Vet> getVetList() {
|
||||||
if (vets == null) {
|
if (vets == null) {
|
||||||
vets = new ArrayList<Vet>();
|
vets = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return vets;
|
return vets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<Owner> findByLastName(String lastName) throws DataAccessException {
|
public Collection<Owner> findByLastName(String lastName) throws DataAccessException {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("lastName", lastName + "%");
|
params.put("lastName", lastName + "%");
|
||||||
List<Owner> owners = this.namedParameterJdbcTemplate.query(
|
List<Owner> owners = this.namedParameterJdbcTemplate.query(
|
||||||
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName",
|
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName",
|
||||||
|
@ -92,7 +92,7 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
public Owner findById(int id) throws DataAccessException {
|
public Owner findById(int id) throws DataAccessException {
|
||||||
Owner owner;
|
Owner owner;
|
||||||
try {
|
try {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("id", id);
|
params.put("id", id);
|
||||||
owner = this.namedParameterJdbcTemplate.queryForObject(
|
owner = this.namedParameterJdbcTemplate.queryForObject(
|
||||||
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
|
"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
|
||||||
|
@ -107,7 +107,7 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadPetsAndVisits(final Owner owner) {
|
public void loadPetsAndVisits(final Owner owner) {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("id", owner.getId());
|
params.put("id", owner.getId());
|
||||||
final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
|
final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
|
||||||
"SELECT pets.id, name, birth_date, type_id, owner_id, visits.id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id",
|
"SELECT pets.id, name, birth_date, type_id, owner_id, visits.id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id",
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PetType> findPetTypes() throws DataAccessException {
|
public List<PetType> findPetTypes() throws DataAccessException {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
return this.namedParameterJdbcTemplate.query(
|
return this.namedParameterJdbcTemplate.query(
|
||||||
"SELECT id, name FROM types ORDER BY name",
|
"SELECT id, name FROM types ORDER BY name",
|
||||||
params,
|
params,
|
||||||
|
@ -84,7 +84,7 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
public Pet findById(int id) throws DataAccessException {
|
public Pet findById(int id) throws DataAccessException {
|
||||||
JdbcPet pet;
|
JdbcPet pet;
|
||||||
try {
|
try {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("id", id);
|
params.put("id", id);
|
||||||
pet = this.namedParameterJdbcTemplate.queryForObject(
|
pet = this.namedParameterJdbcTemplate.queryForObject(
|
||||||
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
|
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class JdbcVetRepositoryImpl implements VetRepository {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<Vet> findAll() throws DataAccessException {
|
public Collection<Vet> findAll() throws DataAccessException {
|
||||||
List<Vet> vets = new ArrayList<Vet>();
|
List<Vet> vets = new ArrayList<>();
|
||||||
// Retrieve the list of all vets.
|
// Retrieve the list of all vets.
|
||||||
vets.addAll(this.jdbcTemplate.query(
|
vets.addAll(this.jdbcTemplate.query(
|
||||||
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
|
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
|
||||||
|
|
Loading…
Reference in a new issue