Ignore:
Timestamp:
03/08/23 17:43:21 (20 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
5dea0b7
Parents:
c03e53b
Message:

fix usages that got broken with the changes

Location:
Prototype Application/Paw5/src/main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/AuthServiceImplementation.java

    rc03e53b re76c5a6  
    33import finki.paw5.model.entities.Adopter;
    44import finki.paw5.model.entities.Employee;
     5import finki.paw5.model.entities.Shelter;
    56import finki.paw5.model.entities.User;
    67import finki.paw5.model.enumerations.FreeTime;
     
    1011import finki.paw5.repository.AdopterRepository;
    1112import finki.paw5.repository.EmployeeRepository;
     13import finki.paw5.repository.ShelterRepository;
    1214import finki.paw5.repository.UserRepository;
    1315import finki.paw5.service.AuthService;
     
    2224    private final AdopterRepository adopterRepository;
    2325    private final EmployeeRepository employeeRepository;
     26    private final ShelterRepository shelterRepository;
    2427
    25     public AuthServiceImplementation(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository) {
     28    public AuthServiceImplementation(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository, ShelterRepository shelterRepository) {
    2629        this.userRepository = userRepository;
    2730        this.adopterRepository = adopterRepository;
    2831        this.employeeRepository = employeeRepository;
     32        this.shelterRepository = shelterRepository;
    2933    }
    3034
     
    4751    @Override
    4852    public Employee registerEmployee(String name, String email, String password, String telephone, String position, Integer shelterId) {
    49         Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelterId,false);
     53        Shelter shelter = this.shelterRepository.findById(shelterId).get();
     54        Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelter,false);
    5055        return employeeRepository.save(employee);
    5156    }
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PetController.java

    rc03e53b re76c5a6  
    11package finki.paw5.web.controllers;
    22
     3import finki.paw5.model.entities.Adopter;
    34import finki.paw5.model.entities.Adoption;
    45import finki.paw5.model.entities.Pet;
    5 import finki.paw5.model.entities.User;
    6 import finki.paw5.model.exceptions.InvalidPetIdException;
    76import finki.paw5.service.AdoptionService;
    87import finki.paw5.service.PetService;
     
    2524    }
    2625
    27     @PostMapping("/submit-adopton-{id}")
     26    @PostMapping("/submit-adoption-{id}")
    2827    public String saveAdoption(@PathVariable Integer id, HttpServletRequest request) {
    2928
    3029        Pet pet = this.petService.findById(id);
    3130       
    32         User user = (User) request.getSession().getAttribute("user");
     31        Adopter adopter = (Adopter) request.getSession().getAttribute("user");
    3332
    34         Adoption adoption = new Adoption(LocalDate.now(), null, false, user.getId());
     33        Adoption adoption = new Adoption(LocalDate.now(), null, false, adopter);
    3534        this.adoptionService.save(adoption);
    3635
    37         pet.setAdoptionId(adoption.getId());
     36        pet.setAdoption(adoption);
    3837        this.petService.save(pet);
    3938
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java

    rc03e53b re76c5a6  
    5858        if(newPetCheckbox == true){
    5959
    60             Pet newPet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelterId());
     60            Pet newPet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelter());
    6161            this.petService.save(newPet);
    6262
    63             Post post = new Post(LocalDate.now(), imageUrl, newPet.getId(), null, employee.getId());
     63            Post post = new Post(LocalDate.now(), imageUrl, newPet, null, employee);
    6464            this.postService.save(post);
    6565
     
    6868            Pet selectedPet = this.petService.findById(petId);
    6969
    70             Post post = new Post(LocalDate.now(), imageUrl, selectedPet.getId(), null, employee.getId());
     70            Post post = new Post(LocalDate.now(), imageUrl, selectedPet, null, employee);
    7171            this.postService.save(post);
    7272
     
    9292
    9393        Post post = this.postService.findById(id).get();
    94         Pet pet = this.petService.findById(post.getPetId());
     94        Pet pet = post.getPet();
    9595
    9696        model.addAttribute("pet", pet);
  • Prototype Application/Paw5/src/main/resources/templates/list-posts-adoption.html

    rc03e53b re76c5a6  
    4747    <tr th:each = "post : ${posts}">
    4848        <td th:text = "${post.getId()}"></td>
    49         <td th:each = "pet : ${pets}" th:if="${post.getPetId()==pet.getId()}" th:text = "${pet.getName()}"></td>
    50         <td th:each = "pet : ${pets}" th:if="${post.getPetId()==pet.getId()}" th:text = "${pet.getSpecies()}"></td>
     49        <td th:text = "${post.getPet().getName()}"></td>
     50        <td th:text = "${post.getPet().getSpecies()}"></td>
    5151        <td>
    5252            <form th:action="@{'/pet-details-{id}' (id=${post.getId()})}"
  • Prototype Application/Paw5/src/main/resources/templates/pet-details.html

    rc03e53b re76c5a6  
    6868</table>
    6969<form method="POST"
    70       th:action="@{'/submit-adopton-{id}' (id=${pet.getId()})}"
    71       th:if="${pet.getAdoptionId()==null}">
     70      th:action="@{'/submit-adoption-{id}' (id=${pet.getId()})}"
     71      th:if="${pet.getAdoption==null}">
    7272    <button id="submit"
    7373            type="submit"
Note: See TracChangeset for help on using the changeset viewer.