Changeset 579bf6d


Ignore:
Timestamp:
02/03/23 10:47:25 (17 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
038c9f7, 1bd0a56, 8ae6217
Parents:
fdfc6fa
Message:

added inheritance

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

Legend:

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

    rfdfc6fa r579bf6d  
    11package finki.paw5.model;
    22
    3 import jakarta.persistence.Column;
    4 import jakarta.persistence.Entity;
    5 import jakarta.persistence.Id;
    6 import jakarta.persistence.Table;
     3import jakarta.persistence.*;
    74import lombok.Data;
     5
     6import java.time.LocalDate;
    87
    98@Data
    109@Entity
    1110@Table(name = "admin_table")
    12 public class Admin {
     11@PrimaryKeyJoinColumn(name = "id_user")
     12public class Admin extends User {
    1313
    14     @Id
    15     @Column(name = "id_user", nullable = false)
    16     private int id;
    17 
    18     public Admin(int id) {
    19         this.id = id;
     14    public Admin(LocalDate dateCreated, String name, String email, String password, String telephone) {
     15        super(dateCreated, name, email, password, telephone);
    2016    }
    2117
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/Adopter.java

    rfdfc6fa r579bf6d  
    55import finki.paw5.model.enumerations.Housing;
    66import finki.paw5.model.enumerations.PhysicalActivity;
    7 import jakarta.persistence.Column;
    8 import jakarta.persistence.Entity;
    9 import jakarta.persistence.Id;
    10 import jakarta.persistence.Table;
     7import jakarta.persistence.*;
    118import lombok.Data;
     9
     10import java.time.LocalDate;
    1211
    1312@Data
    1413@Entity
    1514@Table(name = "adopter")
    16 public class Adopter {
    17 
    18     @Id
    19     @Column(name = "id_user", nullable = false)
    20     private int id;
     15@PrimaryKeyJoinColumn(name = "id_user")
     16public class Adopter extends User {
    2117
    2218    @Column(name = "free_time")
     
    4743    private int verifiedByEmployeeId;
    4844
    49     public Adopter(int id, FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing, PhysicalActivity physicalActivity, boolean willFoster, boolean verified, int verifiedByEmployeeId) {
    50         this.id = id;
     45    public Adopter(LocalDate dateCreated, String name, String email, String password, String telephone,
     46                   FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing,
     47                   PhysicalActivity physicalActivity, boolean willFoster, boolean verified, int verifiedByEmployeeId) {
     48        super(dateCreated, name, email, password, telephone);
     49        this.freeTime = freeTime;
     50        this.funds = funds;
     51        this.hasOtherPets = hasOtherPets;
     52        this.hasKids = hasKids;
     53        this.housing = housing;
     54        this.physicalActivity = physicalActivity;
     55        this.willFoster = willFoster;
     56        this.verified = verified;
     57        this.verifiedByEmployeeId = verifiedByEmployeeId;
     58    }
     59
     60    public Adopter(FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing,
     61                   PhysicalActivity physicalActivity, boolean willFoster, boolean verified, int verifiedByEmployeeId) {
    5162        this.freeTime = freeTime;
    5263        this.funds = funds;
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/Donor.java

    rfdfc6fa r579bf6d  
    11package finki.paw5.model;
    22
    3 import jakarta.persistence.Column;
    4 import jakarta.persistence.Entity;
    5 import jakarta.persistence.Id;
    6 import jakarta.persistence.Table;
     3import jakarta.persistence.*;
    74import lombok.Data;
     5
     6import java.time.LocalDate;
    87
    98@Data
    109@Entity
    1110@Table(name = "donor")
    12 public class Donor {
    13 
    14     @Id
    15     @Column(name = "id_user", nullable = false)
    16     private int id;
     11@PrimaryKeyJoinColumn(name = "id_user")
     12public class Donor extends User {
    1713
    1814    @Column(name = "is_from_organisation", nullable = false)
     
    2218    private String organisationName;
    2319
    24     public Donor(int id, boolean fromOrganisation, String organisationName) {
    25         this.id = id;
     20    public Donor(LocalDate dateCreated, String name, String email, String password, String telephone, boolean fromOrganisation, String organisationName) {
     21        super(dateCreated, name, email, password, telephone);
     22        this.fromOrganisation = fromOrganisation;
     23        this.organisationName = organisationName;
     24    }
     25
     26    public Donor(boolean fromOrganisation, String organisationName) {
    2627        this.fromOrganisation = fromOrganisation;
    2728        this.organisationName = organisationName;
     
    3031    public Donor() {
    3132    }
     33
    3234}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/Employee.java

    rfdfc6fa r579bf6d  
    11package finki.paw5.model;
    22
    3 import jakarta.persistence.Column;
    4 import jakarta.persistence.Entity;
    5 import jakarta.persistence.Id;
    6 import jakarta.persistence.Table;
     3import jakarta.persistence.*;
    74import lombok.Data;
     5
     6import java.time.LocalDate;
    87
    98@Data
    109@Entity
    1110@Table(name = "employee")
    12 public class Employee {
    13 
    14     @Id
    15     @Column(name = "id_user", nullable = false)
    16     private int id;
     11@PrimaryKeyJoinColumn(name = "id_user")
     12public class Employee extends User {
    1713
    1814    @Column(name = "position_employee", nullable = false, length = 20)
     
    2824    private int verifiedByAdminId;
    2925
    30     public Employee() {
    31 
    32     }
    33 
    34     public Employee(int id, String position, int shelterId, boolean verified, int verifiedByAdminId) {
    35         this.id = id;
     26    public Employee(LocalDate dateCreated, String name, String email, String password, String telephone,
     27                    String position, int shelterId, boolean verified, int verifiedByAdminId) {
     28        super(dateCreated, name, email, password, telephone);
    3629        this.position = position;
    3730        this.shelterId = shelterId;
     
    4033    }
    4134
     35    public Employee(String position, int shelterId, boolean verified, int verifiedByAdminId) {
     36        this.position = position;
     37        this.shelterId = shelterId;
     38        this.verified = verified;
     39        this.verifiedByAdminId = verifiedByAdminId;
     40    }
     41
     42    public Employee() {
     43
     44    }
     45
    4246}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/Surendee.java

    rfdfc6fa r579bf6d  
    11package finki.paw5.model;
    22
    3 import jakarta.persistence.Column;
    4 import jakarta.persistence.Entity;
    5 import jakarta.persistence.Id;
    6 import jakarta.persistence.Table;
     3import jakarta.persistence.*;
    74import lombok.Data;
     5
     6import java.time.LocalDate;
    87
    98@Data
    109@Entity
    1110@Table(name = "surendee")
    12 public class Surendee {
     11@PrimaryKeyJoinColumn(name = "id_user")
     12public class Surendee extends User {
    1313
    14     @Id
    15     @Column(name = "id_user", nullable = false)
    16     private int id;
    17 
    18     public Surendee(int id) {
    19         this.id = id;
     14    public Surendee(LocalDate dateCreated, String name, String email, String password, String telephone) {
     15        super(dateCreated, name, email, password, telephone);
    2016    }
    2117
    2218    public Surendee() {
    2319    }
     20
    2421}
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/User.java

    rfdfc6fa r579bf6d  
    11package finki.paw5.model;
    22
    3 import jakarta.persistence.Column;
    4 import jakarta.persistence.Entity;
    5 import jakarta.persistence.Id;
    6 import jakarta.persistence.Table;
     3import jakarta.persistence.*;
    74import lombok.Data;
    85
     
    1310@Entity
    1411@Table(name = "user_table")
     12@Inheritance(strategy = InheritanceType.JOINED)
    1513public class User {
    1614
    1715    @Id
    1816    @Column(name = "id_user")
    19     private int id;
     17    protected int id;
    2018
    2119    @Column(name = "date_created_user", nullable = false)
    22     private LocalDate dateCreated;
     20    protected LocalDate dateCreated;
    2321
    2422    @Column(name = "name_user", nullable = false, length = 100)
    25     private String name;
     23    protected String name;
    2624
    27     @Column(name = "email_user", nullable = false, length = 100, unique=true)
    28     private String email;
     25    @Column(name = "email_user", nullable = false, length = 100, unique = true)
     26    protected String email;
    2927
    3028    @Column(name = "password_user", nullable = false, length = 20)
    31     private String password;
     29    protected String password;
    3230
    3331    @Column(name = "telephone_user", length = 20)
    34     private String telephone;
     32    protected String telephone;
    3533
    3634    public User(LocalDate dateCreated, String name, String email, String password, String telephone) {
Note: See TracChangeset for help on using the changeset viewer.