Ignore:
Timestamp:
03/08/23 17:01:43 (20 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
d1fe9c2
Parents:
8b7dd7f
Message:

fix many to one relations

Location:
Prototype Application/Paw5/src/main/java/finki/paw5/model/entities
Files:
16 edited

Legend:

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

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "admin_table")
    1113@PrimaryKeyJoinColumn(name = "id_user")
    1214public class Admin extends User {
    1315
    14     public Admin(LocalDate dateCreated, String name, String email, String password, String telephone) {
     16    public Admin(LocalDate dateCreated, String name, String email,
     17                 String password, String telephone) {
    1518        super(dateCreated, name, email, password, telephone);
    1619    }
    17 
    18     public Admin() {
    19     }
    2020}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adopter.java

    r8b7dd7f rfdd7961  
    77import jakarta.persistence.*;
    88import lombok.Data;
     9import lombok.RequiredArgsConstructor;
    910
    1011import java.time.LocalDate;
     
    1314@Entity
    1415@Table(name = "adopter")
     16@RequiredArgsConstructor
    1517@PrimaryKeyJoinColumn(name = "id_user")
    1618public class Adopter extends User {
     
    4042    private Boolean verified;
    4143
    42     @Column(name = "verified_by_employee")
    43     private Integer verifiedByEmployeeId;
     44    @ManyToOne
     45    @JoinColumn(name = "verified_by_employee")
     46    Employee employeeVerificator;
    4447
    4548    public Adopter(LocalDate dateCreated, String name, String email, String password, String telephone,
     
    5760    }
    5861
    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     }
    7462}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adoption.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "adoption")
    1113public class Adoption {
     
    2325
    2426    @Column(name = "approved", nullable = false)
    25     private boolean approved;
     27    private Boolean approved;
    2628
    27     @Column(name = "id_adopter", nullable = false)
    28     private Integer adopterId;
     29    @ManyToOne
     30    @JoinColumn(name = "id_adopter", nullable = false)
     31    private Adopter adopter;
    2932
    30     public Adoption(LocalDate startDate, LocalDate endDateFoster, boolean approved, Integer adopterId) {
     33    public Adoption(LocalDate startDate, LocalDate endDateFoster, Boolean approved,
     34                    Adopter adopter) {
    3135        this.startDate = startDate;
    3236        this.endDateFoster = endDateFoster;
    3337        this.approved = approved;
    34         this.adopterId = adopterId;
    35     }
    36 
    37     public Adoption() {
     38        this.adopter = adopter;
    3839    }
    3940}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Category.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67@Data
    78@Entity
     9@RequiredArgsConstructor
    810@Table(name = "category")
    911public class Category {
     
    2123    }
    2224
    23     public Category() {
    24     }
    2525}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Donor.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "donor")
    1113@PrimaryKeyJoinColumn(name = "id_user")
     
    1315
    1416    @Column(name = "is_from_organisation", nullable = false)
    15     private boolean fromOrganisation;
     17    private Boolean fromOrganisation;
    1618
    1719    @Column(name = "name_organisation_donor", nullable = true, length = 100)
    1820    private String organisationName;
    1921
    20     public Donor(LocalDate dateCreated, String name, String email, String password, String telephone, boolean fromOrganisation, String organisationName) {
     22    public Donor(LocalDate dateCreated, String name, String email,
     23                 String password, String telephone, Boolean fromOrganisation,
     24                 String organisationName) {
    2125        super(dateCreated, name, email, password, telephone);
    2226        this.fromOrganisation = fromOrganisation;
     
    2428    }
    2529
    26     public Donor(boolean fromOrganisation, String organisationName) {
    27         this.fromOrganisation = fromOrganisation;
    28         this.organisationName = organisationName;
    29     }
    30 
    31     public Donor() {
    32     }
    33 
    3430}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Employee.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "employee")
    1113@PrimaryKeyJoinColumn(name = "id_user")
     
    1517    private String position;
    1618
    17     @Column(name = "id_shelter", nullable = false)
    18     private Integer shelterId;
     19    @ManyToOne
     20    @JoinColumn(name = "id_shelter", nullable = false)
     21    private Shelter shelter;
    1922
    2023    @Column(name = "is_verified", nullable = false)
    21     private boolean verified;
     24    private Boolean verified;
    2225
    23     @Column(name = "verified_by_admin")
    24     private Integer verifiedByAdminId;
     26    @ManyToOne
     27    @JoinColumn(name = "verified_by_admin")
     28    private Admin adminVerificator;
    2529
    2630    public Employee(LocalDate dateCreated, String name, String email, String password, String telephone,
    27                     String position, int shelterId, boolean verified) {
     31                    String position, Shelter shelter, Boolean verified) {
    2832        super(dateCreated, name, email, password, telephone);
    2933        this.position = position;
    30         this.shelterId = shelterId;
     34        this.shelter = shelter;
    3135        this.verified = verified;
    3236    }
    3337
    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 
    4538}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Food.java

    r8b7dd7f rfdd7961  
    44import jakarta.persistence.*;
    55import lombok.Data;
     6import lombok.RequiredArgsConstructor;
    67
    78@Data
    89@Entity
     10@RequiredArgsConstructor
    911@Table(name = "food")
    1012public class Food {
     
    2931        this.type = type;
    3032    }
    31 
    32     public Food() {
    33     }
    3433}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Organisation.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67@Data
    78@Entity
     9@RequiredArgsConstructor
    810@Table(name = "organisation")
    911public class Organisation {
     
    2830        this.billingInformation = billingInformation;
    2931    }
    30 
    31     public Organisation() {
    32     }
    3332}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/PersonalProfile.java

    r8b7dd7f rfdd7961  
    22
    33import finki.paw5.model.enumerations.*;
    4 import jakarta.persistence.Column;
    5 import jakarta.persistence.Entity;
    6 import jakarta.persistence.Id;
    7 import jakarta.persistence.Table;
     4import jakarta.persistence.*;
    85import lombok.Data;
     6import lombok.RequiredArgsConstructor;
    97
    108@Data
    119@Entity
     10@RequiredArgsConstructor
    1211@Table(name = "personal_profile")
    1312public class PersonalProfile {
     
    1615    @Column(name = "id_pet", nullable = false)
    1716    private Integer id;
     17
     18    @OneToOne
     19    @JoinColumn(name = "id_pet", nullable = false)
     20    private Pet pet;
    1821
    1922    @Column(name = "friendly_to_kids", nullable = false)
     
    3235    private GroomingNeed groomingNeed;
    3336
    34     public PersonalProfile(Integer id, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {
     37    public PersonalProfile(Integer id, Pet pet, FriendlyToKids friendlyToKids, FriendlyToPets friendlyToPets, AttentionNeed attentionNeed, PhysicalActivity physicalActivity, GroomingNeed groomingNeed) {
    3538        this.id = id;
     39        this.pet = pet;
    3640        this.friendlyToKids = friendlyToKids;
    3741        this.friendlyToPets = friendlyToPets;
     
    4044        this.groomingNeed = groomingNeed;
    4145    }
    42 
    43     public PersonalProfile() {
    44     }
    4546}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Pet.java

    r8b7dd7f rfdd7961  
    77import jakarta.persistence.*;
    88import lombok.Data;
     9import lombok.RequiredArgsConstructor;
    910
    1011@Data
    1112@Entity
     13@RequiredArgsConstructor
    1214@Table(name = "pet")
    1315public class Pet {
     
    4042
    4143    @Column(name = "can_be_fostered", nullable = false)
    42     private boolean canBeFostered;
     44    private Boolean canBeFostered;
    4345
    44     @Column(name = "id_adoption")
    45     private Integer adoptionId;
     46    @ManyToOne
     47    @JoinColumn(name = "id_adoption")
     48    private Adoption adoption;
    4649
    47     @Column(name = "id_shelter")
    48     private Integer shelterId;
     50    @ManyToOne
     51    @JoinColumn(name = "id_shelter")
     52    private Shelter shelter;
    4953
    50     public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed, String name, Species species, Gender gender, boolean canBeFostered, Integer adoptionId, Integer shelterId) {
     54    public Pet(String imageUrl, AgeGroup ageGroup, Size size, String breed,
     55               String name, Species species, Gender gender, Boolean canBeFostered,
     56               Adoption adoption, Shelter shelter) {
    5157        this.imageUrl = imageUrl;
    5258        this.ageGroup = ageGroup;
     
    5763        this.gender = gender;
    5864        this.canBeFostered = canBeFostered;
    59         this.adoptionId = adoptionId;
    60         this.shelterId = shelterId;
    61     }
    62 
    63     public Pet() {
     65        this.adoption = adoption;
     66        this.shelter = shelter;
    6467    }
    6568}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "post")
    1113public class Post {
     
    2224    private String thumbnailUrl;
    2325
    24     @Column(name="id_pet", nullable = false)
    25     private Integer petId;
     26    @ManyToOne
     27    @JoinColumn(name="id_pet", nullable = false)
     28    private Pet pet;
    2629
    27     @Column(name="id_surendee")
    28     private Integer surendeeId;
     30    @ManyToOne
     31    @JoinColumn(name="id_surendee")
     32    private Surendee surendeePoster;
    2933
    30     @Column(name="id_employee")
    31     private Integer employeeId;
     34    @ManyToOne
     35    @JoinColumn(name="id_employee")
     36    private Employee employeePoster;
    3237
    33     public Post(LocalDate dateCreated, String thumbnailUrl, Integer petId, Integer surendeeId, Integer employeeId) {
     38    public Post(LocalDate dateCreated, String thumbnailUrl,
     39                Pet pet, Surendee surendeePoster, Employee employeePoster) {
    3440        this.dateCreated = dateCreated;
    3541        this.thumbnailUrl = thumbnailUrl;
    36         this.petId = petId;
    37         this.surendeeId = surendeeId;
    38         this.employeeId = employeeId;
    39     }
    40 
    41     public Post() {
     42        this.pet = pet;
     43        this.surendeePoster = surendeePoster;
     44        this.employeePoster = employeePoster;
    4245    }
    4346}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Shelter.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67@Data
    78@Entity
     9@RequiredArgsConstructor
    810@Table(name = "shelter")
    911public class Shelter {
     
    2022    private String telephone;
    2123
    22     @Column(name = "id_organisation")
    23     private Integer organisationId;
     24    @ManyToOne
     25    @JoinColumn(name = "id_organisation")
     26    private Organisation organisation;
    2427
    2528    @Column(name = "name_shelter", nullable = false, length = 100)
     
    2932    private String email;
    3033
    31     public Shelter(String address, String telephone, Integer organisationId, String name, String email) {
     34    public Shelter(String address, String telephone, Organisation organisation,
     35                   String name, String email) {
    3236        this.address = address;
    3337        this.telephone = telephone;
    34         this.organisationId = organisationId;
     38        this.organisation = organisation;
    3539        this.name = name;
    3640        this.email = email;
    3741    }
    38 
    39     public Shelter() {
    40     }
    4142}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Surendee.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "surendee")
    1113@PrimaryKeyJoinColumn(name = "id_user")
     
    1618    }
    1719
    18     public Surendee() {
    19     }
    20 
    2120}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Therapy.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    910@Data
    1011@Entity
     12@RequiredArgsConstructor
    1113@Table(name = "therapy")
    1214public class Therapy {
     
    3133        this.endDate = endDate;
    3234    }
    33 
    34     public Therapy() {
    35     }
    3635}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/User.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    910@Data
    1011@Entity
     12@RequiredArgsConstructor
    1113@Table(name = "user_table")
    1214@Inheritance(strategy = InheritanceType.JOINED)
     
    4042        this.telephone = telephone;
    4143    }
    42 
    43     public User() {
    44     }
    4544}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/VetClinic.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67@Data
    78@Entity
     9@RequiredArgsConstructor
    810@Table(name = "vet_clinic")
    911public class VetClinic {
     
    2830        this.name = name;
    2931    }
    30 
    31     public VetClinic() {
    32     }
    3332}
Note: See TracChangeset for help on using the changeset viewer.