mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:15:50 +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>
|
||||
|
||||
<!-- Generic properties -->
|
||||
<java.version>1.8</java.version>
|
||||
<java.version>1.7</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
|
|
|
@ -91,13 +91,13 @@ public class Owner extends Person {
|
|||
|
||||
protected Set<Pet> getPetsInternal() {
|
||||
if (this.pets == null) {
|
||||
this.pets = new HashSet<Pet>();
|
||||
this.pets = new HashSet<>();
|
||||
}
|
||||
return this.pets;
|
||||
}
|
||||
|
||||
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));
|
||||
return Collections.unmodifiableList(sortedPets);
|
||||
}
|
||||
|
|
|
@ -94,13 +94,13 @@ public class Pet extends NamedEntity {
|
|||
|
||||
protected Set<Visit> getVisitsInternal() {
|
||||
if (this.visits == null) {
|
||||
this.visits = new HashSet<Visit>();
|
||||
this.visits = new HashSet<>();
|
||||
}
|
||||
return this.visits;
|
||||
}
|
||||
|
||||
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));
|
||||
return Collections.unmodifiableList(sortedVisits);
|
||||
}
|
||||
|
|
|
@ -56,14 +56,14 @@ public class Vet extends Person {
|
|||
|
||||
protected Set<Specialty> getSpecialtiesInternal() {
|
||||
if (this.specialties == null) {
|
||||
this.specialties = new HashSet<Specialty>();
|
||||
this.specialties = new HashSet<>();
|
||||
}
|
||||
return this.specialties;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
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));
|
||||
return Collections.unmodifiableList(sortedSpecs);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class Vets {
|
|||
@XmlElement
|
||||
public List<Vet> getVetList() {
|
||||
if (vets == null) {
|
||||
vets = new ArrayList<Vet>();
|
||||
vets = new ArrayList<>();
|
||||
}
|
||||
return vets;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
|||
*/
|
||||
@Override
|
||||
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 + "%");
|
||||
List<Owner> owners = this.namedParameterJdbcTemplate.query(
|
||||
"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 {
|
||||
Owner owner;
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", id);
|
||||
owner = this.namedParameterJdbcTemplate.queryForObject(
|
||||
"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) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", owner.getId());
|
||||
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",
|
||||
|
|
|
@ -73,7 +73,7 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
|||
|
||||
@Override
|
||||
public List<PetType> findPetTypes() throws DataAccessException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
return this.namedParameterJdbcTemplate.query(
|
||||
"SELECT id, name FROM types ORDER BY name",
|
||||
params,
|
||||
|
@ -84,7 +84,7 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
|||
public Pet findById(int id) throws DataAccessException {
|
||||
JdbcPet pet;
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", id);
|
||||
pet = this.namedParameterJdbcTemplate.queryForObject(
|
||||
"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=:id",
|
||||
|
|
|
@ -60,7 +60,7 @@ public class JdbcVetRepositoryImpl implements VetRepository {
|
|||
*/
|
||||
@Override
|
||||
public Collection<Vet> findAll() throws DataAccessException {
|
||||
List<Vet> vets = new ArrayList<Vet>();
|
||||
List<Vet> vets = new ArrayList<>();
|
||||
// Retrieve the list of all vets.
|
||||
vets.addAll(this.jdbcTemplate.query(
|
||||
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
|
||||
|
|
Loading…
Reference in a new issue