Changes in / [c3278ac:8b7dd7f]
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Admin.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 9 8 @Data 10 9 @Entity 11 @RequiredArgsConstructor12 10 @Table(name = "admin_table") 13 11 @PrimaryKeyJoinColumn(name = "id_user") 14 12 public class Admin extends User { 15 13 16 public Admin(LocalDate dateCreated, String name, String email, 17 String password, String telephone) { 14 public Admin(LocalDate dateCreated, String name, String email, String password, String telephone) { 18 15 super(dateCreated, name, email, password, telephone); 19 16 } 17 18 public Admin() { 19 } 20 20 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adopter.java
rc3278ac r8b7dd7f 7 7 import jakarta.persistence.*; 8 8 import lombok.Data; 9 import lombok.RequiredArgsConstructor;10 9 11 10 import java.time.LocalDate; … … 14 13 @Entity 15 14 @Table(name = "adopter") 16 @RequiredArgsConstructor17 15 @PrimaryKeyJoinColumn(name = "id_user") 18 16 public class Adopter extends User { … … 42 40 private Boolean verified; 43 41 44 @ManyToOne 45 @JoinColumn(name = "verified_by_employee") 46 Employee employeeVerificator; 42 @Column(name = "verified_by_employee") 43 private Integer verifiedByEmployeeId; 47 44 48 45 public Adopter(LocalDate dateCreated, String name, String email, String password, String telephone, … … 60 57 } 61 58 59 public Adopter(FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing, 60 PhysicalActivity physicalActivity, boolean willFoster, boolean verified, int verifiedByEmployeeId) { 61 this.freeTime = freeTime; 62 this.funds = funds; 63 this.hasOtherPets = hasOtherPets; 64 this.hasKids = hasKids; 65 this.housing = housing; 66 this.physicalActivity = physicalActivity; 67 this.willFoster = willFoster; 68 this.verified = verified; 69 this.verifiedByEmployeeId = verifiedByEmployeeId; 70 } 71 72 public Adopter() { 73 } 62 74 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adoption.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 9 8 @Data 10 9 @Entity 11 @RequiredArgsConstructor12 10 @Table(name = "adoption") 13 11 public class Adoption { … … 25 23 26 24 @Column(name = "approved", nullable = false) 27 private Boolean approved;25 private boolean approved; 28 26 29 @ManyToOne 30 @JoinColumn(name = "id_adopter", nullable = false) 31 private Adopter adopter; 27 @Column(name = "id_adopter", nullable = false) 28 private Integer adopterId; 32 29 33 public Adoption(LocalDate startDate, LocalDate endDateFoster, Boolean approved, 34 Adopter adopter) { 30 public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, Integer adopterId) { 35 31 this.startDate = startDate; 36 32 this.endDateFoster = endDateFoster; 37 33 this.approved = approved; 38 this.adopter = adopter; 34 this.adopterId = adopterId; 35 } 36 37 public Adoption() { 39 38 } 40 39 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Category.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 7 import java.util.List;8 5 9 6 @Data 10 7 @Entity 11 @RequiredArgsConstructor12 8 @Table(name = "category") 13 9 public class Category { … … 21 17 private String name; 22 18 23 @ManyToMany24 @JoinTable(name = "pet_belongs_to_category",25 joinColumns = @JoinColumn(name = "id_category"),26 inverseJoinColumns = @JoinColumn(name = "id_pet"))27 List<Pet> pets;28 29 19 public Category(String name) { 30 20 this.name = name; 31 21 } 32 22 23 public Category() { 24 } 33 25 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Donor.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; 8 import java.util.List;9 7 10 8 @Data 11 9 @Entity 12 @RequiredArgsConstructor13 10 @Table(name = "donor") 14 11 @PrimaryKeyJoinColumn(name = "id_user") … … 16 13 17 14 @Column(name = "is_from_organisation", nullable = false) 18 private Boolean fromOrganisation;15 private boolean fromOrganisation; 19 16 20 17 @Column(name = "name_organisation_donor", nullable = true, length = 100) 21 18 private String organisationName; 22 19 23 @ManyToMany 24 @JoinTable(name = "donor_donates_to_organisation", 25 joinColumns = @JoinColumn(name = "id_user"), 26 inverseJoinColumns = @JoinColumn(name = "id_organisation")) 27 List<Organisation> donatedToOrganisations; 28 29 public Donor(LocalDate dateCreated, String name, String email, 30 String password, String telephone, Boolean fromOrganisation, 31 String organisationName) { 20 public Donor(LocalDate dateCreated, String name, String email, String password, String telephone, boolean fromOrganisation, String organisationName) { 32 21 super(dateCreated, name, email, password, telephone); 33 22 this.fromOrganisation = fromOrganisation; … … 35 24 } 36 25 26 public Donor(boolean fromOrganisation, String organisationName) { 27 this.fromOrganisation = fromOrganisation; 28 this.organisationName = organisationName; 29 } 30 31 public Donor() { 32 } 33 37 34 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Employee.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 9 8 @Data 10 9 @Entity 11 @RequiredArgsConstructor12 10 @Table(name = "employee") 13 11 @PrimaryKeyJoinColumn(name = "id_user") … … 17 15 private String position; 18 16 19 @ManyToOne 20 @JoinColumn(name = "id_shelter", nullable = false) 21 private Shelter shelter; 17 @Column(name = "id_shelter", nullable = false) 18 private Integer shelterId; 22 19 23 20 @Column(name = "is_verified", nullable = false) 24 private Boolean verified;21 private boolean verified; 25 22 26 @ManyToOne 27 @JoinColumn(name = "verified_by_admin") 28 private Admin adminVerificator; 23 @Column(name = "verified_by_admin") 24 private Integer verifiedByAdminId; 29 25 30 26 public Employee(LocalDate dateCreated, String name, String email, String password, String telephone, 31 String position, Shelter shelter, Boolean verified) {27 String position, int shelterId, boolean verified) { 32 28 super(dateCreated, name, email, password, telephone); 33 29 this.position = position; 34 this.shelter = shelter;30 this.shelterId = shelterId; 35 31 this.verified = verified; 36 32 } 37 33 34 public Employee(String position, int shelterId, boolean verified, int verifiedByAdminId) { 35 this.position = position; 36 this.shelterId = shelterId; 37 this.verified = verified; 38 this.verifiedByAdminId = verifiedByAdminId; 39 } 40 41 public Employee() { 42 43 } 44 38 45 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Food.java
rc3278ac r8b7dd7f 4 4 import jakarta.persistence.*; 5 5 import lombok.Data; 6 import lombok.RequiredArgsConstructor;7 8 import java.util.List;9 6 10 7 @Data 11 8 @Entity 12 @RequiredArgsConstructor13 9 @Table(name = "food") 14 10 public class Food { … … 28 24 private FoodType type; 29 25 30 @ManyToMany31 @JoinTable(name = "pet_preferably_eats_food",32 joinColumns = @JoinColumn(name = "id_food"),33 inverseJoinColumns = @JoinColumn(name = "id_pet"))34 List<Pet> pets;35 36 26 public Food(String manufacturer, String name, FoodType type) { 37 27 this.manufacturer = manufacturer; … … 39 29 this.type = type; 40 30 } 31 32 public Food() { 33 } 41 34 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Organisation.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 7 import java.util.List;8 5 9 6 @Data 10 7 @Entity 11 @RequiredArgsConstructor12 8 @Table(name = "organisation") 13 9 public class Organisation { … … 27 23 private String billingInformation; 28 24 29 @ManyToMany30 @JoinTable(name = "donor_donates_to_organisation",31 joinColumns = @JoinColumn(name = "id_organisation"),32 inverseJoinColumns = @JoinColumn(name = "id_user"))33 List<Donor> donors;34 35 25 public Organisation(String name, String email, String billingInformation) { 36 26 this.name = name; … … 38 28 this.billingInformation = billingInformation; 39 29 } 30 31 public Organisation() { 32 } 40 33 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java
rc3278ac r8b7dd7f 2 2 3 3 import finki.paw5.model.enumerations.*; 4 import jakarta.persistence.*; 4 import jakarta.persistence.Column; 5 import jakarta.persistence.Entity; 6 import jakarta.persistence.Id; 7 import jakarta.persistence.Table; 5 8 import lombok.Data; 6 import lombok.RequiredArgsConstructor;7 9 8 10 @Data 9 11 @Entity 10 @RequiredArgsConstructor11 12 @Table(name = "personal_profile") 12 13 public class PersonalProfile { … … 15 16 @Column(name = "id_pet", nullable = false) 16 17 private Integer id; 17 18 @OneToOne19 @JoinColumn(name = "id_pet", nullable = false)20 private Pet pet;21 18 22 19 @Column(name = "friendly_to_kids", nullable = false) … … 35 32 private GroomingNeed groomingNeed; 36 33 37 public PersonalProfile(Integer id, Pet pet,FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {34 public PersonalProfile(Integer id, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) { 38 35 this.id = id; 39 this.pet = pet;40 36 this.friendlyToKids = friendlyToKids; 41 37 this.friendlyToPets = friendlyToPets; … … 44 40 this.groomingNeed = groomingNeed; 45 41 } 42 43 public PersonalProfile() { 44 } 46 45 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Pet.java
rc3278ac r8b7dd7f 7 7 import jakarta.persistence.*; 8 8 import lombok.Data; 9 import lombok.RequiredArgsConstructor;10 11 import java.util.List;12 9 13 10 @Data 14 11 @Entity 15 @RequiredArgsConstructor16 12 @Table(name = "pet") 17 13 public class Pet { … … 21 17 @Column(name = "id_pet") 22 18 private Integer id; 23 24 @OneToOne25 @JoinColumn(name = "id_pet", nullable = false)26 private PersonalProfile personalProfile;27 19 28 20 @Column(name = "url_pet_image", length = 200) … … 48 40 49 41 @Column(name = "can_be_fostered", nullable = false) 50 private Boolean canBeFostered;42 private boolean canBeFostered; 51 43 52 @ManyToOne 53 @JoinColumn(name = "id_adoption") 54 private Adoption adoption; 44 @Column(name = "id_adoption") 45 private Integer adoptionId; 55 46 56 @ManyToOne 57 @JoinColumn(name = "id_shelter") 58 private Shelter shelter; 47 @Column(name = "id_shelter") 48 private Integer shelterId; 59 49 60 @ManyToMany 61 @JoinTable(name = "pet_belongs_to_category", 62 joinColumns = @JoinColumn(name = "id_pet"), 63 inverseJoinColumns = @JoinColumn(name = "id_category")) 64 List<Category> categories; 65 66 @ManyToMany 67 @JoinTable(name = "pet_needs_intervention_in_vet_clinic", 68 joinColumns = @JoinColumn(name = "id_pet"), 69 inverseJoinColumns = @JoinColumn(name = "id_vet_clinic")) 70 List<VetClinic> vetClinicsTreatedIn; 71 72 @ManyToMany 73 @JoinTable(name = "pet_needs_therapy", 74 joinColumns = @JoinColumn(name = "id_pet"), 75 inverseJoinColumns = @JoinColumn(name = "id_therapy")) 76 List<Therapy> therapies; 77 78 @ManyToMany 79 @JoinTable(name = "pet_preferably_eats_food", 80 joinColumns = @JoinColumn(name = "id_pet"), 81 inverseJoinColumns = @JoinColumn(name = "id_food")) 82 List<Food> preferredFoods; 83 84 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, 85 String name, Species species, Gender gender, Boolean canBeFostered, 86 Adoption adoption, Shelter shelter) { 50 public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, Integer adoptionId, Integer shelterId) { 87 51 this.imageUrl = imageUrl; 88 52 this.ageGroup = ageGroup; … … 93 57 this.gender = gender; 94 58 this.canBeFostered = canBeFostered; 95 this.adoption = adoption; 96 this.shelter = shelter; 59 this.adoptionId = adoptionId; 60 this.shelterId = shelterId; 61 } 62 63 public Pet() { 97 64 } 98 65 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 9 8 @Data 10 9 @Entity 11 @RequiredArgsConstructor12 10 @Table(name = "post") 13 11 public class Post { … … 24 22 private String thumbnailUrl; 25 23 26 @OneToOne 27 @JoinColumn(name="id_pet", nullable = false) 28 private Pet pet; 24 @Column(name="id_pet", nullable = false) 25 private Integer petId; 29 26 30 @ManyToOne 31 @JoinColumn(name="id_surendee") 32 private Surendee surendeePoster; 27 @Column(name="id_surendee") 28 private Integer surendeeId; 33 29 34 @ManyToOne 35 @JoinColumn(name="id_employee") 36 private Employee employeePoster; 30 @Column(name="id_employee") 31 private Integer employeeId; 37 32 38 public Post(LocalDate dateCreated, String thumbnailUrl, 39 Pet pet, Surendee surendeePoster, Employee employeePoster) { 33 public Post(LocalDate dateCreated, String thumbnailUrl, Integer petId, Integer surendeeId, Integer employeeId) { 40 34 this.dateCreated = dateCreated; 41 35 this.thumbnailUrl = thumbnailUrl; 42 this.pet = pet; 43 this.surendeePoster = surendeePoster; 44 this.employeePoster = employeePoster; 36 this.petId = petId; 37 this.surendeeId = surendeeId; 38 this.employeeId = employeeId; 39 } 40 41 public Post() { 45 42 } 46 43 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Shelter.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 @Data 8 7 @Entity 9 @RequiredArgsConstructor10 8 @Table(name = "shelter") 11 9 public class Shelter { … … 22 20 private String telephone; 23 21 24 @ManyToOne 25 @JoinColumn(name = "id_organisation") 26 private Organisation organisation; 22 @Column(name = "id_organisation") 23 private Integer organisationId; 27 24 28 25 @Column(name = "name_shelter", nullable = false, length = 100) … … 32 29 private String email; 33 30 34 public Shelter(String address, String telephone, Organisation organisation, 35 String name, String email) { 31 public Shelter(String address, String telephone, Integer organisationId, String name, String email) { 36 32 this.address = address; 37 33 this.telephone = telephone; 38 this.organisation = organisation;34 this.organisationId = organisationId; 39 35 this.name = name; 40 36 this.email = email; 41 37 } 38 39 public Shelter() { 40 } 42 41 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Surendee.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 9 8 @Data 10 9 @Entity 11 @RequiredArgsConstructor12 10 @Table(name = "surendee") 13 11 @PrimaryKeyJoinColumn(name = "id_user") … … 18 16 } 19 17 18 public Surendee() { 19 } 20 20 21 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Therapy.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; 8 7 import java.util.Date; 9 import java.util.List;10 8 11 9 @Data 12 10 @Entity 13 @RequiredArgsConstructor14 11 @Table(name = "therapy") 15 12 public class Therapy { … … 29 26 private LocalDate endDate; 30 27 31 @ManyToMany32 @JoinTable(name = "pet_needs_therapy",33 joinColumns = @JoinColumn(name = "id_therapy"),34 inverseJoinColumns = @JoinColumn(name = "id_pet"))35 List<Pet> pets;36 37 28 public Therapy(String healthProblem, LocalDate startDate, LocalDate endDate) { 38 29 this.healthProblem = healthProblem; … … 40 31 this.endDate = endDate; 41 32 } 33 34 public Therapy() { 35 } 42 36 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/User.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 10 9 @Data 11 10 @Entity 12 @RequiredArgsConstructor13 11 @Table(name = "user_table") 14 12 @Inheritance(strategy = InheritanceType.JOINED) … … 42 40 this.telephone = telephone; 43 41 } 42 43 public User() { 44 } 44 45 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/VetClinic.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 7 import java.util.List;8 5 9 6 @Data 10 7 @Entity 11 @RequiredArgsConstructor12 8 @Table(name = "vet_clinic") 13 9 public class VetClinic { … … 27 23 private String name; 28 24 29 @ManyToMany30 @JoinTable(name = "pet_needs_intervention_in_vet_clinic",31 joinColumns = @JoinColumn(name = "id_vet_clinic"),32 inverseJoinColumns = @JoinColumn(name = "id_pet"))33 List<Pet> pets;34 35 25 public VetClinic(String telephone, String address, String name) { 36 26 this.telephone = telephone; … … 38 28 this.name = name; 39 29 } 30 31 public VetClinic() { 32 } 40 33 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/DonorDonatesToOrganisation.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 @Data 8 7 @Entity 9 @RequiredArgsConstructor10 8 @Table(name = "donor_donates_to_organisation") 11 9 @IdClass(DonorDonatesToOrganisationId.class) … … 24 22 this.organisationId = organisationId; 25 23 } 24 25 public DonorDonatesToOrganisation() { 26 27 } 26 28 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetBelongsToCategory.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 @Data 8 7 @Entity 9 @RequiredArgsConstructor10 8 @Table(name = "pet_belongs_to_category") 11 9 @IdClass(PetBelongsToCategoryId.class) … … 24 22 this.categoryId = categoryId; 25 23 } 24 25 public PetBelongsToCategory() { 26 27 } 26 28 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetNeedsInterventionInVetClinic.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 import java.time.LocalDate; … … 10 9 @Data 11 10 @Entity 12 @RequiredArgsConstructor13 11 @Table(name = "pet_needs_intervention_in_vet_clinic") 14 12 @IdClass(PetNeedsInterventionInVetClinicId.class) … … 35 33 this.description = description; 36 34 } 35 36 public PetNeedsInterventionInVetClinic() { 37 38 } 37 39 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetNeedsTherapy.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 @Data 8 7 @Entity 9 @RequiredArgsConstructor10 8 @Table(name = "pet_needs_therapy") 11 9 @IdClass(PetNeedsTherapyId.class) … … 24 22 this.therapyId = therapyId; 25 23 } 24 25 public PetNeedsTherapy() { 26 } 26 27 } -
Prototype Application/Paw5/src/main/java/finki/paw5/model/relations/PetPreferablyEatsFood.java
rc3278ac r8b7dd7f 3 3 import jakarta.persistence.*; 4 4 import lombok.Data; 5 import lombok.RequiredArgsConstructor;6 5 7 6 @Data 8 7 @Entity 9 @RequiredArgsConstructor10 8 @Table(name = "pet_preferably_eats_food") 11 9 @IdClass(PetPreferablyEatsFoodId.class) … … 28 26 this.quantityPerDay = quantityPerDay; 29 27 } 28 29 public PetPreferablyEatsFood() { 30 } 30 31 } -
Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/AuthServiceImplementation.java
rc3278ac r8b7dd7f 3 3 import finki.paw5.model.entities.Adopter; 4 4 import finki.paw5.model.entities.Employee; 5 import finki.paw5.model.entities.Shelter;6 5 import finki.paw5.model.entities.User; 7 6 import finki.paw5.model.enumerations.FreeTime; … … 11 10 import finki.paw5.repository.AdopterRepository; 12 11 import finki.paw5.repository.EmployeeRepository; 13 import finki.paw5.repository.ShelterRepository;14 12 import finki.paw5.repository.UserRepository; 15 13 import finki.paw5.service.AuthService; … … 24 22 private final AdopterRepository adopterRepository; 25 23 private final EmployeeRepository employeeRepository; 26 private final ShelterRepository shelterRepository;27 24 28 public AuthServiceImplementation(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository , ShelterRepository shelterRepository) {25 public AuthServiceImplementation(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository) { 29 26 this.userRepository = userRepository; 30 27 this.adopterRepository = adopterRepository; 31 28 this.employeeRepository = employeeRepository; 32 this.shelterRepository = shelterRepository;33 29 } 34 30 … … 51 47 @Override 52 48 public Employee registerEmployee(String name, String email, String password, String telephone, String position, Integer shelterId) { 53 Shelter shelter = this.shelterRepository.findById(shelterId).get(); 54 Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelter,false); 49 Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelterId,false); 55 50 return employeeRepository.save(employee); 56 51 } -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PetController.java
rc3278ac r8b7dd7f 1 1 package finki.paw5.web.controllers; 2 2 3 import finki.paw5.model.entities.Adopter;4 3 import finki.paw5.model.entities.Adoption; 5 4 import finki.paw5.model.entities.Pet; 5 import finki.paw5.model.entities.User; 6 import finki.paw5.model.exceptions.InvalidPetIdException; 6 7 import finki.paw5.service.AdoptionService; 7 8 import finki.paw5.service.PetService; … … 24 25 } 25 26 26 @PostMapping("/submit-adopt ion-{id}")27 @PostMapping("/submit-adopton-{id}") 27 28 public String saveAdoption(@PathVariable Integer id, HttpServletRequest request) { 28 29 29 30 Pet pet = this.petService.findById(id); 30 31 31 Adopter adopter = (Adopter) request.getSession().getAttribute("user");32 User user = (User) request.getSession().getAttribute("user"); 32 33 33 Adoption adoption = new Adoption(LocalDate.now(), null, false, adopter);34 Adoption adoption = new Adoption(LocalDate.now(), null, false, user.getId()); 34 35 this.adoptionService.save(adoption); 35 36 36 pet.setAdoption (adoption);37 pet.setAdoptionId(adoption.getId()); 37 38 this.petService.save(pet); 38 39 -
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
rc3278ac r8b7dd7f 58 58 if(newPetCheckbox == true){ 59 59 60 Pet newPet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelter ());60 Pet newPet = new Pet(imageUrl, AgeGroup.valueOf(ageGroup), Size.valueOf(size), breed, name, Species.valueOf(species), Gender.valueOf(gender), canBeFostered, null, employee.getShelterId()); 61 61 this.petService.save(newPet); 62 62 63 Post post = new Post(LocalDate.now(), imageUrl, newPet , null, employee);63 Post post = new Post(LocalDate.now(), imageUrl, newPet.getId(), null, employee.getId()); 64 64 this.postService.save(post); 65 65 … … 68 68 Pet selectedPet = this.petService.findById(petId); 69 69 70 Post post = new Post(LocalDate.now(), imageUrl, selectedPet , null, employee);70 Post post = new Post(LocalDate.now(), imageUrl, selectedPet.getId(), null, employee.getId()); 71 71 this.postService.save(post); 72 72 … … 92 92 93 93 Post post = this.postService.findById(id).get(); 94 Pet pet = post.getPet();94 Pet pet = this.petService.findById(post.getPetId()); 95 95 96 96 model.addAttribute("pet", pet); -
Prototype Application/Paw5/src/main/resources/templates/list-posts-adoption.html
rc3278ac r8b7dd7f 47 47 <tr th:each = "post : ${posts}"> 48 48 <td th:text = "${post.getId()}"></td> 49 <td th: text = "${post.getPet().getName()}"></td>50 <td th: text = "${post.getPet().getSpecies()}"></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> 51 51 <td> 52 52 <form th:action="@{'/pet-details-{id}' (id=${post.getId()})}" -
Prototype Application/Paw5/src/main/resources/templates/pet-details.html
rc3278ac r8b7dd7f 68 68 </table> 69 69 <form method="POST" 70 th:action="@{'/submit-adopt ion-{id}' (id=${pet.getId()})}"71 th:if="${pet.getAdoption ()==null}">70 th:action="@{'/submit-adopton-{id}' (id=${pet.getId()})}" 71 th:if="${pet.getAdoptionId()==null}"> 72 72 <button id="submit" 73 73 type="submit"
Note:
See TracChangeset
for help on using the changeset viewer.