Skip to content

Commit

Permalink
Update Profiles to Use Spring Data JPA Services. Closes #48
Browse files Browse the repository at this point in the history
  • Loading branch information
falconsmilie committed Feb 7, 2020
1 parent 6062d23 commit 0a31cdb
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void delete(T object) {

private Long getNextId() {

Long nextId = null;
Long nextId;

try {
nextId = Collections.max(map.keySet()) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import guru.springframework.sfgpetclinic.services.OwnerService;
import guru.springframework.sfgpetclinic.services.PetService;
import guru.springframework.sfgpetclinic.services.PetTypeService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Profile({"default", "map"})
public class OwnerMapService extends AbstractMapService<Owner, Long> implements OwnerService {

private final PetTypeService petTypeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import guru.springframework.sfgpetclinic.model.Pet;
import guru.springframework.sfgpetclinic.services.PetService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Profile({"default", "map"})
public class PetMapService extends AbstractMapService<Pet, Long> implements PetService {
@Override
public Set<Pet> findAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import guru.springframework.sfgpetclinic.model.PetType;
import guru.springframework.sfgpetclinic.services.PetTypeService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Profile({"default", "map"})
public class PetTypeMapService extends AbstractMapService<PetType, Long> implements PetTypeService {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import guru.springframework.sfgpetclinic.model.Specialty;
import guru.springframework.sfgpetclinic.services.SpecialtyService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Profile({"default", "map"})
public class SpecialtyMapService extends AbstractMapService<Specialty, Long> implements SpecialtyService {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import guru.springframework.sfgpetclinic.model.Vet;
import guru.springframework.sfgpetclinic.services.SpecialtyService;
import guru.springframework.sfgpetclinic.services.VetService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Profile({"default", "map"})
public class VetMapService extends AbstractMapService<Vet, Long> implements VetService {

private final SpecialtyService specialtyService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import guru.springframework.sfgpetclinic.model.Visit;
import guru.springframework.sfgpetclinic.services.VisitService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
@Profile({"default", "map"})
public class VisitMapService extends AbstractMapService<Visit, Long> implements VisitService {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Set;

@Service
@Profile("sprindatajpa")
@Profile("springdatajpa")
public class OwnerSDJpaService implements OwnerService {

private final OwnerRepository ownerRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Set;

@Service
@Profile("sprindatajpa")
@Profile("springdatajpa")
public class PetSDJpaService implements PetService {

private final PetRepository petRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Set;

@Service
@Profile("sprindatajpa")
@Profile("springdatajpa")
public class SpecialtySDJpaService implements SpecialtyService {

private final SpecialtyRepository specialtyRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DataLoader(OwnerService ownerService,
}

@Override
public void run(String... args) throws Exception {
public void run(String... args) {

int count = petTypeService.findAll().size();

Expand Down
4 changes: 3 additions & 1 deletion pet-clinic-web/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ spring.banner.image.location=avatar.jpg
server.port=8181

# internationalisation
spring.messages.basename=messages/messages
spring.messages.basename=messages/messages

spring.profiles.active=springdatajpa

0 comments on commit 0a31cdb

Please sign in to comment.