Changes in / [eac569a:f194b4e]


Ignore:
Location:
Prototype Application/Paw5/src/main
Files:
7 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adoption.java

    reac569a rf194b4e  
    55
    66import java.time.LocalDate;
     7import java.util.Date;
    78
    89@Data
     
    2627
    2728    @Column(name = "id_adopter", nullable = false)
    28     private Integer adopterId;
     29    private int adopterId;
    2930
    30     public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, Integer adopterId) {
     31    public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, int adopterId) {
    3132        this.startDate = startDate;
    3233        this.endDateFoster = endDateFoster;
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java

    reac569a rf194b4e  
    3232    private GroomingNeed groomingNeed;
    3333
    34     public PersonalProfile(Integer id, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {
     34    public PersonalProfile(int id, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {
    3535        this.id = id;
    3636        this.friendlyToKids = friendlyToKids;
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/PostService.java

    reac569a rf194b4e  
    22
    33import finki.paw5.model.entities.Post;
    4 import java.util.List;
    5 import java.util.Optional;
    64
    75public interface PostService {
     
    97    void save (Post post);
    108
    11     List<Post> findAll();
    12 
    13     Optional<Post> findById(Integer id);
    149}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/ShelterService.java

    reac569a rf194b4e  
    44
    55import java.util.List;
    6 import java.util.Optional;
    76
    87public interface ShelterService {
    9     Optional<Shelter> findById(Integer id);
    108    List<Shelter> listShelters();
    119}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PetServiceImplementation.java

    reac569a rf194b4e  
    2222    }
    2323
     24    @Override
    2425    public List<Pet> listpets() {return this.petRepository.findAll();}
    2526
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/PostServiceImplementation.java

    reac569a rf194b4e  
    55import finki.paw5.service.PostService;
    66import org.springframework.stereotype.Service;
    7 
    8 import java.util.List;
    9 import java.util.Optional;
    107
    118@Service
     
    2320    }
    2421
    25     @Override
    26     public List<Post> findAll() {
    27         return this.postRepository.findAll();
    28     }
    29 
    30     @Override
    31     public Optional<Post> findById(Integer id) {
    32         return this.postRepository.findById(id);
    33     }
    3422}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/ShelterServiceImplementation.java

    reac569a rf194b4e  
    77
    88import java.util.List;
    9 import java.util.Optional;
    109
    1110@Service
    1211public class ShelterServiceImplementation implements ShelterService {
    13 
    1412    private final ShelterRepository shelterRepository;
    1513
     
    1816    }
    1917
    20     @Override
    21     public Optional<Shelter> findById(Integer id) {
    22         return this.shelterRepository.findById(id);
    23     }
    2418
    2519    @Override
     
    2721        return shelterRepository.findAll();
    2822    }
    29 
    30 
    3123}
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PetController.java

    reac569a rf194b4e  
    11package finki.paw5.web.controllers;
    22
    3 import finki.paw5.model.entities.Adoption;
    4 import finki.paw5.model.entities.Pet;
    5 import finki.paw5.model.entities.User;
    6 import finki.paw5.model.exceptions.InvalidPetIdException;
    7 import finki.paw5.service.AdoptionService;
    83import finki.paw5.service.PetService;
    9 import jakarta.servlet.http.HttpServletRequest;
    104import org.springframework.stereotype.Controller;
    11 import org.springframework.web.bind.annotation.PathVariable;
    12 import org.springframework.web.bind.annotation.PostMapping;
    13 
    14 import java.time.LocalDate;
    155
    166@Controller
     
    188
    199    private final PetService petService;
    20     private final AdoptionService adoptionService;
    2110
    22     public PetController(PetService petService, AdoptionService adoptionService) {
     11    public PetController(PetService petService) {
    2312        this.petService = petService;
    24         this.adoptionService = adoptionService;
    2513    }
    2614
    27     @PostMapping("/submit-adopton-{id}")
    28     public String saveAdoption(@PathVariable Integer id, HttpServletRequest request) {
    29 
    30         Pet pet = this.petService.findById(id);
    31        
    32         User user = (User) request.getSession().getAttribute("user");
    33 
    34         Adoption adoption = new Adoption(LocalDate.now(), null, false, user.getId());
    35         this.adoptionService.save(adoption);
    36 
    37         pet.setAdoptionId(adoption.getId());
    38         this.petService.save(pet);
    39 
    40         return "redirect:/home";
    41     }
    4215}
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java

    reac569a rf194b4e  
    11package finki.paw5.web.controllers;
     2
     3import finki.paw5.model.entities.Employee;
    24import finki.paw5.model.entities.Pet;
    35import finki.paw5.model.entities.Post;
    4 import finki.paw5.model.entities.Employee;
     6import finki.paw5.model.entities.User;
    57import finki.paw5.model.enumerations.AgeGroup;
    68import finki.paw5.model.enumerations.Gender;
    79import finki.paw5.model.enumerations.Size;
    810import finki.paw5.model.enumerations.Species;
    9 import finki.paw5.service.PersonalProfileService;
    1011import finki.paw5.service.PetService;
    1112import finki.paw5.service.PostService;
    12 import finki.paw5.service.ShelterService;
    1313import jakarta.servlet.http.HttpServletRequest;
    1414import org.springframework.stereotype.Controller;
    1515import org.springframework.ui.Model;
    1616import org.springframework.web.bind.annotation.GetMapping;
    17 import org.springframework.web.bind.annotation.PathVariable;
    1817import org.springframework.web.bind.annotation.PostMapping;
    1918import org.springframework.web.bind.annotation.RequestParam;
    2019
    2120import java.time.LocalDate;
    22 import java.util.List;
    2321
    2422@Controller
     
    2725    private final PostService postService;
    2826    private final PetService petService;
    29     private final PersonalProfileService personalProfileService;
    3027
    31     public PostController(PostService postService, PetService petService, PersonalProfileService personalProfileService, ShelterService shelterService) {
     28    public PostController(PostService postService, PetService petService) {
    3229        this.postService = postService;
    3330        this.petService = petService;
    34         this.personalProfileService = personalProfileService;
    3531    }
    3632
     
    7571        return "redirect:/home";
    7672    }
    77 
    78     @GetMapping("/adoption-posts")
    79     public String getAdoptionPosts(Model model, HttpServletRequest request){
    80 
    81         List<Post> posts = this.postService.findAll();
    82         List<Pet> pets = this.petService.listpets();
    83         //model.addAttribute("posts", posts);
    84         //model.addAttribute("pets",pets);
    85         request.getSession().setAttribute("posts",posts);//temp
    86         request.getSession().setAttribute("pets",pets);//temp
    87 
    88         return "list-posts-adoption";
    89     }
    90 
    91     @GetMapping("/pet-details-{id}")
    92     public String getPostDetails(@PathVariable Integer id, Model model, HttpServletRequest request){
    93 
    94         Post post = this.postService.findById(id).get();
    95         Pet pet = this.petService.findById(post.getPetId());
    96 
    97         //model.addAttribute("pet", pet);
    98         //model.addAttribute("post", post);
    99         request.getSession().setAttribute("post", post);//temp
    100         request.getSession().setAttribute("pet", pet);//temp
    101 
    102         if(pet.getAdoptionId() != null){
    103             request.getSession().setAttribute("disableAdoption", true);
    104         } else{
    105             request.getSession().setAttribute("disableAdoption", false);
    106         }
    107 
    108         return "pet-details";
    109     }
    11073}
  • Prototype Application/Paw5/src/main/resources/templates/aboutUs.html

    reac569a rf194b4e  
    4040    <h5 class="text-center text-danger">
    4141        You successfully logged in
    42         <th:block  th:text="${session.user?.getId()}"></th:block>
     42        <th:block  th:text="${session.user.getId()}"></th:block>
    4343    </h5>
    4444</div>
  • Prototype Application/Paw5/src/main/resources/templates/home.html

    reac569a rf194b4e  
    4343  <h1>Welcome to Paw 5</h1>
    4444  <h3>Let's get started
    45     <th:block  th:text="${session.user?.getName()}"></th:block>
     45    <th:block  th:text="${session.user.getName()}"></th:block>
    4646  </h3>
    4747</div>
    48 <div>
    49   <form method="get" th:action="@{'/adoption-posts'}">
    50     <button id="submit" type="submit">View Adoption posts</button>
    51   </form>
    52 </div>
     48
    5349</body>
    5450</html>
Note: See TracChangeset for help on using the changeset viewer.