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)
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Cursus")
private int cursusId;
private Cursus cursus;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Course")
private int courseId;
private Course course;
public CursusCourse(int cursusId, int courseId){
this.cursusId = cursusId;
this.courseId = courseId;
public CursusCourse(Cursus cursus, Course course){
this.cursus = cursus;
this.course = course;
}
public CursusCourse() {}
@ -25,19 +27,19 @@ public class CursusCourse {
return id;
}
public int getCourseId() {
return courseId;
public Course getCourse() {
return course;
}
public void setCourseId(int courseId){
this.courseId = courseId;
public void setCourse(Course course){
this.course = course;
}
public int getCursusId() {
return cursusId;
public Cursus getCursus() {
return cursus;
}
public void setCursusId(int cursusId) {
this.cursusId = cursusId;
public void setCursus(Cursus cursus) {
this.cursus = cursus;
}
}

View File

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

View File

@ -8,18 +8,21 @@ public class TeacherGivenCourse {
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Users")
private int regNo;
private User user;
@ManyToOne(fetch = FetchType.LAZY)
@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)
private boolean owned;
public TeacherGivenCourse(int regNo, int courseId, boolean owned){
this.regNo = regNo;
this.courseId = courseId;
public TeacherGivenCourse(User user, Course course, boolean owned){
this.user = user;
this.course = course;
this.owned = owned;
}
@ -29,20 +32,20 @@ public class TeacherGivenCourse {
return id;
}
public int getRegNo() {
return regNo;
public User getUser() {
return user;
}
public void setRegNo(int regNo) {
this.regNo = regNo;
public void setUser(User user) {
this.user = user;
}
public int getCourseId() {
return courseId;
public Course getCourse() {
return course;
}
public void setCourseId(int courseId) {
this.courseId = courseId;
public void setCourse(Course course) {
this.course = course;
}
public boolean isOwned() {

View File

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