forked from TEAMMATES/teammates
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEAMMATES#12946] Initialise Entities for Course Structure (TEAMMATES…
…#12948) * Initialise DDL for Course Structure * Resolve PR comments - Add courseStructures to Course - Remove teamToStudentMaps from Team as superseded by Students --------- Co-authored-by: Wei Qing <[email protected]>
- Loading branch information
Showing
8 changed files
with
190 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/main/java/teammates/storage/sqlentity/CourseStructure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package teammates.storage.sqlentity; | ||
|
||
import java.time.Instant; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
|
||
/** | ||
* Represents a Course Structure. | ||
*/ | ||
@Entity | ||
@Table(name = "CourseStructures") | ||
public class CourseStructure extends BaseEntity { | ||
@Id | ||
private UUID id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "courseId") | ||
private Course course; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@OneToMany(mappedBy = "section", cascade = CascadeType.ALL) | ||
private List<Section> sections = new ArrayList<>(); | ||
|
||
@UpdateTimestamp | ||
private Instant updatedAt; | ||
|
||
protected CourseStructure() { | ||
// required by Hibernate | ||
} | ||
|
||
public CourseStructure(UUID id, Course course, String name) { | ||
this.id = id; | ||
this.course = course; | ||
this.name = name; | ||
} | ||
|
||
public UUID getId() { | ||
return this.id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CourseStructure [id=" + id + ", course=" + course.getId() | ||
+ ", createdAt=" + super.getCreatedAt() + ", updatedAt=" + updatedAt + "]"; | ||
} | ||
|
||
@Override | ||
public List<String> getInvalidityInfo() { | ||
List<String> errors = new ArrayList<>(); | ||
|
||
return errors; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == null) { | ||
return false; | ||
} else if (this == other) { | ||
return true; | ||
} else if (this.getClass() == other.getClass()) { | ||
CourseStructure otherCourseStructure = (CourseStructure) other; | ||
return Objects.equals(this.getId(), otherCourseStructure.getId()); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return this.getId().hashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/teammates/storage/sqlentity/TeamToStudentMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package teammates.storage.sqlentity; | ||
|
||
import java.time.Instant; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToMany; | ||
import jakarta.persistence.Table; | ||
|
||
/** | ||
* Represents a Team to Student Map. | ||
*/ | ||
@Entity | ||
@Table(name = "TeamToStudentMaps") | ||
public class TeamToStudentMap extends BaseEntity { | ||
@Id | ||
private UUID id; | ||
|
||
@ManyToMany | ||
@JoinColumn(name = "teamId") | ||
private Team team; | ||
|
||
@ManyToMany | ||
@JoinColumn(name = "studentId") | ||
private Student student; | ||
|
||
@UpdateTimestamp | ||
private Instant updatedAt; | ||
|
||
public UUID getId() { | ||
return this.id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TeamToStudentMap [id=" + id + ", team=" + team.getId() + ", student=" + student.getId() | ||
+ ", createdAt=" + super.getCreatedAt() + ", updatedAt=" + updatedAt + "]"; | ||
} | ||
|
||
@Override | ||
public List<String> getInvalidityInfo() { | ||
List<String> errors = new ArrayList<>(); | ||
|
||
return errors; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == null) { | ||
return false; | ||
} else if (this == other) { | ||
return true; | ||
} else if (this.getClass() == other.getClass()) { | ||
TeamToStudentMap otherTeamToStudentMap = (TeamToStudentMap) other; | ||
return Objects.equals(this.id, otherTeamToStudentMap.getId()); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return this.getId().hashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters