mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Add Clinic Service extended interface and implementation
This commit is contained in:
parent
80aa6ad178
commit
4dd164d01b
2 changed files with 213 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
||||||
|
package org.springframework.samples.petclinic.service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.samples.petclinic.model.Owner;
|
||||||
|
import org.springframework.samples.petclinic.model.Pet;
|
||||||
|
import org.springframework.samples.petclinic.model.PetType;
|
||||||
|
import org.springframework.samples.petclinic.model.Specialty;
|
||||||
|
import org.springframework.samples.petclinic.model.Vet;
|
||||||
|
import org.springframework.samples.petclinic.model.Visit;
|
||||||
|
|
||||||
|
public interface ClinicServiceExt extends ClinicService {
|
||||||
|
|
||||||
|
// Pet findPetById(int id) throws DataAccessException;
|
||||||
|
Collection<Pet> findAllPets() throws DataAccessException;
|
||||||
|
// void savePet(Pet pet) throws DataAccessException;
|
||||||
|
void deletePet(Pet pet) throws DataAccessException;
|
||||||
|
|
||||||
|
// Collection<Visit> findVisitsByPetId(int petId);
|
||||||
|
Visit findVisitById(int visitId) throws DataAccessException;
|
||||||
|
Collection<Visit> findAllVisits() throws DataAccessException;
|
||||||
|
// void saveVisit(Visit visit) throws DataAccessException;
|
||||||
|
void deleteVisit(Visit visit) throws DataAccessException;
|
||||||
|
|
||||||
|
Vet findVetById(int id) throws DataAccessException;
|
||||||
|
// Collection<Vet> findVets() throws DataAccessException;
|
||||||
|
Collection<Vet> findAllVets() throws DataAccessException;
|
||||||
|
void saveVet(Vet vet) throws DataAccessException;
|
||||||
|
void deleteVet(Vet vet) throws DataAccessException;
|
||||||
|
|
||||||
|
// Owner findOwnerById(int id) throws DataAccessException;
|
||||||
|
Collection<Owner> findAllOwners() throws DataAccessException;
|
||||||
|
// void saveOwner(Owner owner) throws DataAccessException;
|
||||||
|
void deleteOwner(Owner owner) throws DataAccessException;
|
||||||
|
// Collection<Owner> findOwnerByLastName(String lastName) throws DataAccessException;
|
||||||
|
|
||||||
|
PetType findPetTypeById(int petTypeId);
|
||||||
|
Collection<PetType> findAllPetTypes() throws DataAccessException;
|
||||||
|
// Collection<PetType> findPetTypes() throws DataAccessException;
|
||||||
|
void savePetType(PetType petType) throws DataAccessException;
|
||||||
|
void deletePetType(PetType petType) throws DataAccessException;
|
||||||
|
|
||||||
|
Specialty findSpecialtyById(int specialtyId);
|
||||||
|
Collection<Specialty> findAllSpecialties() throws DataAccessException;
|
||||||
|
void saveSpecialty(Specialty specialty) throws DataAccessException;
|
||||||
|
void deleteSpecialty(Specialty specialty) throws DataAccessException;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
package org.springframework.samples.petclinic.service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.samples.petclinic.model.Owner;
|
||||||
|
import org.springframework.samples.petclinic.model.Pet;
|
||||||
|
import org.springframework.samples.petclinic.model.PetType;
|
||||||
|
import org.springframework.samples.petclinic.model.Specialty;
|
||||||
|
import org.springframework.samples.petclinic.model.Vet;
|
||||||
|
import org.springframework.samples.petclinic.model.Visit;
|
||||||
|
import org.springframework.samples.petclinic.repository.OwnerRepositoryExt;
|
||||||
|
import org.springframework.samples.petclinic.repository.PetRepositoryExt;
|
||||||
|
import org.springframework.samples.petclinic.repository.PetTypeRepositoryExt;
|
||||||
|
import org.springframework.samples.petclinic.repository.SpecialtyRepositoryExt;
|
||||||
|
import org.springframework.samples.petclinic.repository.VetRepositoryExt;
|
||||||
|
import org.springframework.samples.petclinic.repository.VisitRepositoryExt;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ClinicServiceExtImpl extends ClinicServiceImpl implements ClinicServiceExt {
|
||||||
|
|
||||||
|
private SpecialtyRepositoryExt specialtyRepositoryExt;
|
||||||
|
private PetTypeRepositoryExt petTypeRepositoryExt;
|
||||||
|
private PetRepositoryExt petRepositoryExt;
|
||||||
|
private VetRepositoryExt vetRepositoryExt;
|
||||||
|
private OwnerRepositoryExt ownerRepositoryExt;
|
||||||
|
private VisitRepositoryExt visitRepositoryExt;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ClinicServiceExtImpl(
|
||||||
|
@Qualifier("PetRepositoryExt") PetRepositoryExt petRepositoryExt,
|
||||||
|
@Qualifier("VetRepositoryExt") VetRepositoryExt vetRepositoryExt,
|
||||||
|
@Qualifier("OwnerRepositoryExt") OwnerRepositoryExt ownerRepositoryExt,
|
||||||
|
@Qualifier("VisitRepositoryExt") VisitRepositoryExt visitRepositoryExt,
|
||||||
|
@Qualifier("SpecialtyRepositoryExt") SpecialtyRepositoryExt specialtyRepositoryExt,
|
||||||
|
@Qualifier("PetTypeRepositoryExt") PetTypeRepositoryExt petTypeRepositoryExt) {
|
||||||
|
super(petRepositoryExt, vetRepositoryExt, ownerRepositoryExt, visitRepositoryExt);
|
||||||
|
this.specialtyRepositoryExt = specialtyRepositoryExt;
|
||||||
|
this.petTypeRepositoryExt = petTypeRepositoryExt;
|
||||||
|
this.petRepositoryExt = petRepositoryExt;
|
||||||
|
this.vetRepositoryExt = vetRepositoryExt;
|
||||||
|
this.ownerRepositoryExt = ownerRepositoryExt;
|
||||||
|
this.visitRepositoryExt = visitRepositoryExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Collection<Pet> findAllPets() throws DataAccessException {
|
||||||
|
return petRepositoryExt.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deletePet(Pet pet) throws DataAccessException {
|
||||||
|
petRepositoryExt.delete(pet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Visit findVisitById(int visitId) throws DataAccessException {
|
||||||
|
return visitRepositoryExt.findById(visitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Collection<Visit> findAllVisits() throws DataAccessException {
|
||||||
|
return visitRepositoryExt.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deleteVisit(Visit visit) throws DataAccessException {
|
||||||
|
visitRepositoryExt.delete(visit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Vet findVetById(int id) throws DataAccessException {
|
||||||
|
return vetRepositoryExt.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Collection<Vet> findAllVets() throws DataAccessException {
|
||||||
|
return vetRepositoryExt.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void saveVet(Vet vet) throws DataAccessException {
|
||||||
|
vetRepositoryExt.save(vet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deleteVet(Vet vet) throws DataAccessException {
|
||||||
|
vetRepositoryExt.delete(vet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Collection<Owner> findAllOwners() throws DataAccessException {
|
||||||
|
return ownerRepositoryExt.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deleteOwner(Owner owner) throws DataAccessException {
|
||||||
|
ownerRepositoryExt.delete(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public PetType findPetTypeById(int petTypeId) {
|
||||||
|
return petTypeRepositoryExt.findById(petTypeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Collection<PetType> findAllPetTypes() throws DataAccessException {
|
||||||
|
return petTypeRepositoryExt.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void savePetType(PetType petType) throws DataAccessException {
|
||||||
|
petTypeRepositoryExt.save(petType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deletePetType(PetType petType) throws DataAccessException {
|
||||||
|
petTypeRepositoryExt.delete(petType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Specialty findSpecialtyById(int specialtyId) {
|
||||||
|
return specialtyRepositoryExt.findById(specialtyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Collection<Specialty> findAllSpecialties() throws DataAccessException {
|
||||||
|
return specialtyRepositoryExt.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void saveSpecialty(Specialty specialty) throws DataAccessException {
|
||||||
|
specialtyRepositoryExt.save(specialty);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deleteSpecialty(Specialty specialty) throws DataAccessException {
|
||||||
|
specialtyRepositoryExt.delete(specialty);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue