mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 05:25:50 +00:00
Minor fixes - indentation mostly
This commit is contained in:
parent
06be7eb5be
commit
66227140aa
33 changed files with 117 additions and 169 deletions
|
@ -32,7 +32,6 @@ public class BaseEntity {
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
protected Integer id;
|
protected Integer id;
|
||||||
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.springframework.samples.petclinic.model;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects
|
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as a base class for objects
|
||||||
* needing these properties.
|
* needing these properties.
|
||||||
|
@ -32,7 +31,6 @@ public class NamedEntity extends BaseEntity {
|
||||||
@Column(name = "name")
|
@Column(name = "name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@ public class Owner extends Person {
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
||||||
private Set<Pet> pets;
|
private Set<Pet> pets;
|
||||||
|
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return this.address;
|
return this.address;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,5 +52,4 @@ public class Person extends BaseEntity {
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,6 @@ public class Pet extends NamedEntity {
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER)
|
||||||
private Set<Visit> visits;
|
private Set<Visit> visits;
|
||||||
|
|
||||||
|
|
||||||
public void setBirthDate(DateTime birthDate) {
|
public void setBirthDate(DateTime birthDate) {
|
||||||
this.birthDate = birthDate;
|
this.birthDate = birthDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class Vet extends Person {
|
||||||
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
||||||
private Set<Specialty> specialties;
|
private Set<Specialty> specialties;
|
||||||
|
|
||||||
|
|
||||||
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
|
protected void setSpecialtiesInternal(Set<Specialty> specialties) {
|
||||||
this.specialties = specialties;
|
this.specialties = specialties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2013 the original author or authors.
|
||||||
*
|
*
|
||||||
|
|
|
@ -57,7 +57,6 @@ public class Visit extends BaseEntity {
|
||||||
@JoinColumn(name = "pet_id")
|
@JoinColumn(name = "pet_id")
|
||||||
private Pet pet;
|
private Pet pet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of Visit for the current date
|
* Creates a new instance of Visit for the current date
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +64,6 @@ public class Visit extends BaseEntity {
|
||||||
this.date = new DateTime();
|
this.date = new DateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for property date.
|
* Getter for property date.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
/*
|
|
||||||
* Copyright 2002-2013 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2013 the original author or authors.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,5 +38,4 @@ public interface VetRepository {
|
||||||
*/
|
*/
|
||||||
Collection<Vet> findAll() throws DataAccessException;
|
Collection<Vet> findAll() throws DataAccessException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads {@link Owner Owners} from the data store by last name, returning all owners whose last name <i>starts</i> with
|
* Loads {@link Owner Owners} from the data store by last name, returning all owners whose last name <i>starts</i> with
|
||||||
* the given name; also loads the {@link Pet Pets} and {@link Visit Visits} for the corresponding owners, if not
|
* the given name; also loads the {@link Pet Pets} and {@link Visit Visits} for the corresponding owners, if not
|
||||||
|
@ -109,7 +108,9 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
public void loadPetsAndVisits(final Owner owner) {
|
public void loadPetsAndVisits(final Owner owner) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
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 as visit_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 as visit_id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id",
|
||||||
params,
|
params,
|
||||||
new JdbcPetVisitExtractor()
|
new JdbcPetVisitExtractor()
|
||||||
|
@ -151,5 +152,4 @@ public class JdbcOwnerRepositoryImpl implements OwnerRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ class JdbcPet extends Pet {
|
||||||
|
|
||||||
private int ownerId;
|
private int ownerId;
|
||||||
|
|
||||||
|
|
||||||
public void setTypeId(int typeId) {
|
public void setTypeId(int typeId) {
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class JdbcPetRepositoryImpl implements PetRepository {
|
||||||
|
|
||||||
private VisitRepository visitRepository;
|
private VisitRepository visitRepository;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public JdbcPetRepositoryImpl(DataSource dataSource, OwnerRepository ownerRepository, VisitRepository visitRepository) {
|
public JdbcPetRepositoryImpl(DataSource dataSource, OwnerRepository ownerRepository, VisitRepository visitRepository) {
|
||||||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||||
|
|
|
@ -54,7 +54,6 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
||||||
.usingGeneratedKeyColumns("id");
|
.usingGeneratedKeyColumns("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Visit visit) throws DataAccessException {
|
public void save(Visit visit) throws DataAccessException {
|
||||||
if (visit.isNew()) {
|
if (visit.isNew()) {
|
||||||
|
@ -66,7 +65,6 @@ public class JdbcVisitRepositoryImpl implements VisitRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit} instance.
|
* Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit} instance.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.repository.jdbc;
|
package org.springframework.samples.petclinic.repository.jdbc;
|
||||||
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.samples.petclinic.model.Visit;
|
import org.springframework.samples.petclinic.model.Visit;
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Important: in the current version of this method, we load Owners with all their Pets and Visits while
|
* Important: in the current version of this method, we load Owners with all their Pets and Visits while
|
||||||
* we do not need Visits at all and we only need one property from the Pet objects (the 'name' property).
|
* we do not need Visits at all and we only need one property from the Pet objects (the 'name' property).
|
||||||
|
@ -67,7 +66,6 @@ public class JpaOwnerRepositoryImpl implements OwnerRepository {
|
||||||
return (Owner) query.getSingleResult();
|
return (Owner) query.getSingleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Owner owner) {
|
public void save(Owner owner) {
|
||||||
if (owner.getId() == null) {
|
if (owner.getId() == null) {
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class JpaVetRepositoryImpl implements VetRepository {
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "vets")
|
@Cacheable(value = "vets")
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -42,7 +42,6 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Visit visit) {
|
public void save(Visit visit) {
|
||||||
if (visit.getId() == null) {
|
if (visit.getId() == null) {
|
||||||
|
@ -53,7 +52,6 @@ public class JpaVisitRepositoryImpl implements VisitRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<Visit> findByPetId(Integer petId) {
|
public List<Visit> findByPetId(Integer petId) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.springframework.samples.petclinic.model.PetType;
|
||||||
import org.springframework.samples.petclinic.model.Vet;
|
import org.springframework.samples.petclinic.model.Vet;
|
||||||
import org.springframework.samples.petclinic.model.Visit;
|
import org.springframework.samples.petclinic.model.Visit;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mostly used as a facade so all controllers have a single point of entry
|
* Mostly used as a facade so all controllers have a single point of entry
|
||||||
*
|
*
|
||||||
|
|
|
@ -78,14 +78,12 @@ public class ClinicServiceImpl implements ClinicService {
|
||||||
ownerRepository.save(owner);
|
ownerRepository.save(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void saveVisit(Visit visit) throws DataAccessException {
|
public void saveVisit(Visit visit) throws DataAccessException {
|
||||||
visitRepository.save(visit);
|
visitRepository.save(visit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Pet findPetById(int id) throws DataAccessException {
|
public Pet findPetById(int id) throws DataAccessException {
|
||||||
|
@ -105,5 +103,4 @@ public class ClinicServiceImpl implements ClinicService {
|
||||||
return vetRepository.findAll();
|
return vetRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ public class CallMonitoringAspect {
|
||||||
|
|
||||||
private long accumulatedCallTime = 0;
|
private long accumulatedCallTime = 0;
|
||||||
|
|
||||||
|
|
||||||
@ManagedAttribute
|
@ManagedAttribute
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
|
@ -72,7 +71,6 @@ public class CallMonitoringAspect {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Around("within(@org.springframework.stereotype.Repository *)")
|
@Around("within(@org.springframework.stereotype.Repository *)")
|
||||||
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
|
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
if (this.enabled) {
|
if (this.enabled) {
|
||||||
|
|
|
@ -36,5 +36,4 @@ public class CrashController {
|
||||||
"happens when an exception is thrown");
|
"happens when an exception is thrown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class OwnerController {
|
||||||
|
|
||||||
private final ClinicService clinicService;
|
private final ClinicService clinicService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public OwnerController(ClinicService clinicService) {
|
public OwnerController(ClinicService clinicService) {
|
||||||
this.clinicService = clinicService;
|
this.clinicService = clinicService;
|
||||||
|
@ -101,8 +100,7 @@ public class OwnerController {
|
||||||
// 1 owner found
|
// 1 owner found
|
||||||
owner = results.iterator().next();
|
owner = results.iterator().next();
|
||||||
return "redirect:/owners/" + owner.getId();
|
return "redirect:/owners/" + owner.getId();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// multiple owners found
|
// multiple owners found
|
||||||
model.put("selections", results);
|
model.put("selections", results);
|
||||||
return "owners/ownersList";
|
return "owners/ownersList";
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class PetController {
|
||||||
|
|
||||||
private final ClinicService clinicService;
|
private final ClinicService clinicService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PetController(ClinicService clinicService) {
|
public PetController(ClinicService clinicService) {
|
||||||
this.clinicService = clinicService;
|
this.clinicService = clinicService;
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic.web;
|
package org.springframework.samples.petclinic.web;
|
||||||
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -41,7 +40,6 @@ public class PetTypeFormatter implements Formatter<PetType> {
|
||||||
|
|
||||||
private final ClinicService clinicService;
|
private final ClinicService clinicService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PetTypeFormatter(ClinicService clinicService) {
|
public PetTypeFormatter(ClinicService clinicService) {
|
||||||
this.clinicService = clinicService;
|
this.clinicService = clinicService;
|
||||||
|
|
|
@ -61,5 +61,4 @@ public class PetValidator implements Validator {
|
||||||
return Pet.class.equals(clazz);
|
return Pet.class.equals(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ public class VetController {
|
||||||
|
|
||||||
private final ClinicService clinicService;
|
private final ClinicService clinicService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public VetController(ClinicService clinicService) {
|
public VetController(ClinicService clinicService) {
|
||||||
this.clinicService = clinicService;
|
this.clinicService = clinicService;
|
||||||
|
@ -60,5 +59,4 @@ public class VetController {
|
||||||
return vets;
|
return vets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class VisitController {
|
||||||
|
|
||||||
private final ClinicService clinicService;
|
private final ClinicService clinicService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public VisitController(ClinicService clinicService) {
|
public VisitController(ClinicService clinicService) {
|
||||||
this.clinicService = clinicService;
|
this.clinicService = clinicService;
|
||||||
|
|
Loading…
Reference in a new issue