1
0
forked from PGL/Clyde

- On objectise tout

- Ajout des relation
This commit is contained in:
LeoMoulin 2024-03-06 20:05:24 +01:00
parent 4a85a55290
commit 434cc8dd2b
4 changed files with 56 additions and 46 deletions

View File

@ -8,15 +8,17 @@ public class CursusCourse {
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private int id; private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Cursus") @JoinColumn(name = "Cursus")
private int cursusId; private Cursus cursus;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Course") @JoinColumn(name = "Course")
private int courseId; private Course course;
public CursusCourse(int cursusId, int courseId){ public CursusCourse(Cursus cursus, Course course){
this.cursusId = cursusId; this.cursus = cursus;
this.courseId = courseId; this.course = course;
} }
public CursusCourse() {} public CursusCourse() {}
@ -25,19 +27,19 @@ public class CursusCourse {
return id; return id;
} }
public int getCourseId() { public Course getCourse() {
return courseId; return course;
} }
public void setCourseId(int courseId){ public void setCourse(Course course){
this.courseId = courseId; this.course = course;
} }
public int getCursusId() { public Cursus getCursus() {
return cursusId; return cursus;
} }
public void setCursusId(int cursusId) { public void setCursus(Cursus cursus) {
this.cursusId = cursusId; this.cursus = cursus;
} }
} }

View File

@ -8,12 +8,13 @@ public class Secretary {
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private int id; private int id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Users") @JoinColumn(name = "Users")
private int regNo; private User user;
private String faculty; private String faculty;
public Secretary(int regNo, String faculty){ public Secretary(User user, String faculty){
this.regNo = regNo; this.user = user;
this.faculty = faculty; this.faculty = faculty;
} }
@ -23,12 +24,12 @@ public class Secretary {
return id; return id;
} }
public int getRegNo() { public User getUser() {
return regNo; return user;
} }
public void setRegNo(int regNo) { public void setUser(User user) {
this.regNo = regNo; this.user = user;
} }
public String getFaculty() { public String getFaculty() {

View File

@ -8,18 +8,21 @@ public class TeacherGivenCourse {
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private int id; private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Users") @JoinColumn(name = "Users")
private int regNo; private User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Course") @JoinColumn(name = "Course")
private int courseId; private Course course;
//This flag helps make the difference between an assistant or a Teacher (who owns the course) //This flag helps make the difference between an assistant or a Teacher (who owns the course)
private boolean owned; private boolean owned;
public TeacherGivenCourse(int regNo, int courseId, boolean owned){ public TeacherGivenCourse(User user, Course course, boolean owned){
this.regNo = regNo; this.user = user;
this.courseId = courseId; this.course = course;
this.owned = owned; this.owned = owned;
} }
@ -29,20 +32,20 @@ public class TeacherGivenCourse {
return id; return id;
} }
public int getRegNo() { public User getUser() {
return regNo; return user;
} }
public void setRegNo(int regNo) { public void setUser(User user) {
this.regNo = regNo; this.user = user;
} }
public int getCourseId() { public Course getCourse() {
return courseId; return course;
} }
public void setCourseId(int courseId) { public void setCourse(Course course) {
this.courseId = courseId; this.course = course;
} }
public boolean isOwned() { public boolean isOwned() {

View File

@ -7,15 +7,19 @@ public class UserCursus {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private int id; private int id;
//Un étudiant peut avoir plusieurs cursus
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Users") @JoinColumn(name = "Users")
private int regNo; private User user;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Cursus") @JoinColumn(name = "Cursus")
private int cursusId; private Cursus cursus;
public UserCursus(int regNo, int cursusId){ public UserCursus(User user, Cursus cursus){
this.regNo = regNo; this.user = user;
this.cursusId = cursusId; this.cursus = cursus;
} }
public UserCursus() {} public UserCursus() {}
@ -24,19 +28,19 @@ public class UserCursus {
return id; return id;
} }
public int getRegNo() { public User getUser() {
return regNo; return user;
} }
public void setRegNo(int regNo) { public void setUser(User user) {
this.regNo = regNo; this.user = user;
} }
public int getCursusId() { public Cursus getCursus() {
return cursusId; return cursus;
} }
public void setCursusId(int cursusId) { public void setCursus(Cursus cursus) {
this.cursusId = cursusId; this.cursus = cursus;
} }
} }