From d4de7b387aee1981b9281be3bd0ba30e69fee513 Mon Sep 17 00:00:00 2001 From: vahido9 <97857304+vahido9@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:00:54 -0400 Subject: [PATCH 1/3] added more models (attrs are not final yet) --- .../sysc4806/project/models/Professor.java | 63 +++++++++++ .../java/sysc4806/project/models/Program.java | 10 ++ .../java/sysc4806/project/models/Project.java | 81 ++++++++++++-- .../java/sysc4806/project/models/Student.java | 100 ++++++++++++++++++ 4 files changed, 246 insertions(+), 8 deletions(-) create mode 100644 src/main/java/sysc4806/project/models/Professor.java create mode 100644 src/main/java/sysc4806/project/models/Program.java create mode 100644 src/main/java/sysc4806/project/models/Student.java diff --git a/src/main/java/sysc4806/project/models/Professor.java b/src/main/java/sysc4806/project/models/Professor.java new file mode 100644 index 0000000..7d0aab5 --- /dev/null +++ b/src/main/java/sysc4806/project/models/Professor.java @@ -0,0 +1,63 @@ +package sysc4806.project.models; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; + +import java.util.Date; + +@Entity +public class Professor { + + @Id + @GeneratedValue + private long id; + + private String name; + + private String email; + + private String password; + + private Date oralPresentationAvailability; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Date getOralPresentationAvailability() { + return oralPresentationAvailability; + } + + public void setOralPresentationAvailability(Date oralPresentationAvailability) { + this.oralPresentationAvailability = oralPresentationAvailability; + } +} diff --git a/src/main/java/sysc4806/project/models/Program.java b/src/main/java/sysc4806/project/models/Program.java new file mode 100644 index 0000000..7e6608f --- /dev/null +++ b/src/main/java/sysc4806/project/models/Program.java @@ -0,0 +1,10 @@ +package sysc4806.project.models; + +public enum Program { + MECHANICAL_ENGINEERING, + CIVIL_ENGINEERING, + SOFTWARE_ENGINEERING, + ELECTRICAL_ENGINEERING, + COMPUTER_ENGINEERING, + CHEMICAL_ENGINEERING +} diff --git a/src/main/java/sysc4806/project/models/Project.java b/src/main/java/sysc4806/project/models/Project.java index 4be8785..6523f52 100644 --- a/src/main/java/sysc4806/project/models/Project.java +++ b/src/main/java/sysc4806/project/models/Project.java @@ -1,8 +1,10 @@ package sysc4806.project.models; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; +import jakarta.persistence.*; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Entity public class Project { @@ -10,14 +12,37 @@ public class Project { @GeneratedValue private long id; - private String name; + private String title; + + private String description; + + private Date deadline; + + private int maxStudents; + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + private List students; + + @ManyToOne + private Professor professors; + + public Project() { + this.students = new ArrayList<>(); + } - public String getName() { - return name; + public Project(String title, String description, Date deadline) { + this.title= title; + this.description = description; + this.deadline = deadline; + this.students = new ArrayList<>(); } - public void setName(String name) { - this.name = name; + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; } public long getId() { @@ -27,4 +52,44 @@ public long getId() { public void setId(long id) { this.id = id; } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getDeadline() { + return deadline; + } + + public void setDeadline(Date deadline) { + this.deadline = deadline; + } + + public Professor getProfessors() { + return professors; + } + + public int getMaxStudents() { + return maxStudents; + } + + public void setMaxStudents(int maxStudents) { + this.maxStudents = maxStudents; + } + + public List getStudents() { + return students; + } + + public void addStudent(Student student) { + students.add(student); + } + + public void removeStudent(Student student) { + students.remove(student); + } } diff --git a/src/main/java/sysc4806/project/models/Student.java b/src/main/java/sysc4806/project/models/Student.java new file mode 100644 index 0000000..8b71f76 --- /dev/null +++ b/src/main/java/sysc4806/project/models/Student.java @@ -0,0 +1,100 @@ +package sysc4806.project.models; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; + +import java.util.Date; + +@Entity +public class Student { + + @Id + @GeneratedValue + private long id; + + private String name; + + private String email; + + private String password; + + private Program program; + + private Date oralPresentationAvailability; + + @ManyToOne + private Project project; + + public Student() { + } + + public Student(String name, + String email, + String password, + Program program, + Date oralPresentationAvailability) { + this.name = name; + this.email = email; + this.password = password; + this.program = program; + this.oralPresentationAvailability = oralPresentationAvailability; + } + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project = project; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Program getProgram() { + return program; + } + + public void setProgram(Program program) { + this.program = program; + } + + public Date getOralPresentationAvailability() { + return oralPresentationAvailability; + } + + public void setOralPresentationAvailability(Date oralPresentationAvailability) { + this.oralPresentationAvailability = oralPresentationAvailability; + } +} From 2d30361e3812a5ed4d64362069bc3e40f85d1e59 Mon Sep 17 00:00:00 2001 From: vahido9 <97857304+vahido9@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:09:20 -0400 Subject: [PATCH 2/3] javadoc --- .../sysc4806/project/models/Professor.java | 45 ++++++++++++++ .../java/sysc4806/project/models/Program.java | 3 + .../java/sysc4806/project/models/Project.java | 55 +++++++++++++++++ .../java/sysc4806/project/models/Student.java | 59 +++++++++++++++++++ 4 files changed, 162 insertions(+) diff --git a/src/main/java/sysc4806/project/models/Professor.java b/src/main/java/sysc4806/project/models/Professor.java index 7d0aab5..ea14aa6 100644 --- a/src/main/java/sysc4806/project/models/Professor.java +++ b/src/main/java/sysc4806/project/models/Professor.java @@ -6,6 +6,9 @@ import java.util.Date; +/** + * Professor model + */ @Entity public class Professor { @@ -21,42 +24,84 @@ public class Professor { private Date oralPresentationAvailability; + public Professor() {} + + /** + * Get professor's id + * @return long + */ public long getId() { return id; } + /** + * Set professor's id + * @param id long + */ public void setId(long id) { this.id = id; } + /** + * Get professor's name + * @return String + */ public String getName() { return name; } + /** + * Set professor's name + * @param name String + */ public void setName(String name) { this.name = name; } + /** + * Get professor's email + * @return String + */ public String getEmail() { return email; } + /** + * Set professor's email + * @param email String + */ public void setEmail(String email) { this.email = email; } + /** + * Get professor's password + * @return String + */ public String getPassword() { return password; } + /** + * Set professor's password + * @param password String + */ public void setPassword(String password) { this.password = password; } + /** + * Get professor's oral presentation availability + * @return Date + */ public Date getOralPresentationAvailability() { return oralPresentationAvailability; } + /** + * Set professor's oral presentation availability + * @param oralPresentationAvailability Date + */ public void setOralPresentationAvailability(Date oralPresentationAvailability) { this.oralPresentationAvailability = oralPresentationAvailability; } diff --git a/src/main/java/sysc4806/project/models/Program.java b/src/main/java/sysc4806/project/models/Program.java index 7e6608f..c9cfe1f 100644 --- a/src/main/java/sysc4806/project/models/Program.java +++ b/src/main/java/sysc4806/project/models/Program.java @@ -1,5 +1,8 @@ package sysc4806.project.models; +/** + * Program enumerator for all possible programs students can be apart of. + */ public enum Program { MECHANICAL_ENGINEERING, CIVIL_ENGINEERING, diff --git a/src/main/java/sysc4806/project/models/Project.java b/src/main/java/sysc4806/project/models/Project.java index 6523f52..fb35800 100644 --- a/src/main/java/sysc4806/project/models/Project.java +++ b/src/main/java/sysc4806/project/models/Project.java @@ -6,6 +6,9 @@ import java.util.Date; import java.util.List; +/** + * Project model + */ @Entity public class Project { @Id @@ -37,58 +40,110 @@ public Project(String title, String description, Date deadline) { this.students = new ArrayList<>(); } + /** + * Get project title + */ public String getTitle() { return title; } + /** + * Set project title + * @param title String + */ public void setTitle(String title) { this.title = title; } + /** + * Get project id + */ public long getId() { return id; } + /** + * Set project id + * @param id long + */ public void setId(long id) { this.id = id; } + /** + * Get project description + */ public String getDescription() { return description; } + /** + * Set project description + * @param description String + */ public void setDescription(String description) { this.description = description; } + /** + * Get project deadline + */ public Date getDeadline() { return deadline; } + /** + * Set project deadline + * @param deadline Date + */ public void setDeadline(Date deadline) { this.deadline = deadline; } + /** + * Get project professor(s) + * @return Professor + */ public Professor getProfessors() { return professors; } + /** + * Get maximum number of students assigned to a project + * @return int maximum amount of students on project + */ public int getMaxStudents() { return maxStudents; } + /** + * Set maximum number of students for a project + * @param maxStudents int maximum number of students on project + */ public void setMaxStudents(int maxStudents) { this.maxStudents = maxStudents; } + /** + * Get students assigned to the project + * @return List of students on the project + */ public List getStudents() { return students; } + /** + * Add a student to the project + * @param student Student to be added to the project + */ public void addStudent(Student student) { students.add(student); } + /** + * Remove student from the project + * @param student Student to be removed from the project + */ public void removeStudent(Student student) { students.remove(student); } diff --git a/src/main/java/sysc4806/project/models/Student.java b/src/main/java/sysc4806/project/models/Student.java index 8b71f76..ae464dc 100644 --- a/src/main/java/sysc4806/project/models/Student.java +++ b/src/main/java/sysc4806/project/models/Student.java @@ -7,6 +7,9 @@ import java.util.Date; +/** + * Student model + */ @Entity public class Student { @@ -42,58 +45,114 @@ public Student(String name, this.oralPresentationAvailability = oralPresentationAvailability; } + /** + * Get students project + * @return Project + */ public Project getProject() { return project; } + /** + * Set students project + * @param project Project + */ public void setProject(Project project) { this.project = project; } + /** + * Get student's id + * @return long + */ public long getId() { return id; } + /** + * Set student's id + * @param id long + */ public void setId(long id) { this.id = id; } + /** + * Get student's name + * @return String + */ public String getName() { return name; } + /** + * Set student's name + * @param name String + */ public void setName(String name) { this.name = name; } + /** + * Get student's email + * @return String + */ public String getEmail() { return email; } + /** + * Set student's email + * @param email String + */ public void setEmail(String email) { this.email = email; } + /** + * Get student's password + * @return String + */ public String getPassword() { return password; } + /** + * Set student's password + * @param password String + */ public void setPassword(String password) { this.password = password; } + /** + * Get student's program + * @return Program + */ public Program getProgram() { return program; } + /** + * Set student's program + * @param program Program + */ public void setProgram(Program program) { this.program = program; } + /** + * Get student's oral presentation availability + * @return Date + */ public Date getOralPresentationAvailability() { return oralPresentationAvailability; } + /** + * Set student's oral presentation availability + * @param oralPresentationAvailability Date + */ public void setOralPresentationAvailability(Date oralPresentationAvailability) { this.oralPresentationAvailability = oralPresentationAvailability; } From a60403ffb5222c7b39263db67f976cab1192e0cd Mon Sep 17 00:00:00 2001 From: vahido9 <97857304+vahido9@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:10:42 -0400 Subject: [PATCH 3/3] removed deadline from project --- .../java/sysc4806/project/models/Project.java | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/main/java/sysc4806/project/models/Project.java b/src/main/java/sysc4806/project/models/Project.java index fb35800..dffa201 100644 --- a/src/main/java/sysc4806/project/models/Project.java +++ b/src/main/java/sysc4806/project/models/Project.java @@ -19,8 +19,6 @@ public class Project { private String description; - private Date deadline; - private int maxStudents; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @@ -33,10 +31,10 @@ public Project() { this.students = new ArrayList<>(); } - public Project(String title, String description, Date deadline) { + public Project(String title, String description, int maxStudents) { this.title= title; this.description = description; - this.deadline = deadline; + this.maxStudents = maxStudents; this.students = new ArrayList<>(); } @@ -85,21 +83,6 @@ public void setDescription(String description) { this.description = description; } - /** - * Get project deadline - */ - public Date getDeadline() { - return deadline; - } - - /** - * Set project deadline - * @param deadline Date - */ - public void setDeadline(Date deadline) { - this.deadline = deadline; - } - /** * Get project professor(s) * @return Professor