task/3382: Harmonisera tabellnamn #6
@ -23,7 +23,15 @@ import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "final_seminar")
|
||||
@ -35,27 +43,69 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
||||
public static final int DEFAULT_MAX_PARTICIPANTS = 5;
|
||||
public static final String FINAL_SEMINAR = "finalSeminar";
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@QueryInit({"projectType", "headSupervisor"})
|
||||
private Project project;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "start_date")
|
||||
private Date startDate;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "room")
|
||||
private String room;
|
||||
|
||||
@Basic
|
||||
@Column(name = "max_opponents")
|
||||
private int maxOpponents = DEFAULT_MAX_OPPONENTS;
|
||||
|
||||
@Basic
|
||||
@Column(name = "max_participants")
|
||||
private int maxParticipants = DEFAULT_MAX_PARTICIPANTS;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "presentation_lang")
|
||||
private Language presentationLanguage;
|
||||
|
||||
@Basic
|
||||
@Column(name = "document_upload_date")
|
||||
private Date documentUploadDate;
|
||||
|
||||
@Basic
|
||||
@Column(name = "extra_info")
|
||||
private String extraInfo;
|
||||
|
||||
@Basic
|
||||
@Column(name = "creation_reason")
|
||||
private String creationReason;
|
||||
|
||||
@Basic
|
||||
@Column(name = "manual_participants")
|
||||
private Boolean manualParticipants = false;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (final_seminar) referencing other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
/*
|
||||
* Cascading delete, set document to nul will delete the filedescription but
|
||||
* not the actual file. Use FinarSeminarUploadController.deleteSeminarReport
|
||||
* to delete the document
|
||||
*/
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "file_reference_id", referencedColumnName = "id")
|
||||
tozh4728 marked this conversation as resolved
Outdated
|
||||
private FileReference document;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
@QueryInit({"projectType", "headSupervisor"})
|
||||
private Project project;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of other tables referencing to this table "final_seminar"
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToMany(mappedBy = FINAL_SEMINAR, orphanRemoval = true, cascade = CascadeType.ALL)
|
||||
private Set<FinalSeminarActiveParticipation> activeParticipations = new HashSet<>();
|
||||
|
||||
@ -65,28 +115,10 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
||||
@OneToMany(mappedBy = FINAL_SEMINAR, orphanRemoval = true, cascade = CascadeType.ALL)
|
||||
private Set<FinalSeminarRespondent> respondents = new HashSet<>();
|
||||
|
||||
/*
|
||||
* Cascading delete, set document to nul will delete the filedescription but
|
||||
* not the actual file. Use FinarSeminarUploadController.deleteSeminarReport
|
||||
* to delete the document
|
||||
*/
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "document_reference_id")
|
||||
private FileReference document;
|
||||
|
||||
private Date documentUploadDate;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Language presentationLanguage;
|
||||
|
||||
private int maxOpponents = DEFAULT_MAX_OPPONENTS;
|
||||
private int maxParticipants = DEFAULT_MAX_PARTICIPANTS;
|
||||
|
||||
@Basic
|
||||
private String creationReason;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------------------
|
||||
public FinalSeminar() {
|
||||
|
||||
}
|
||||
|
||||
public FinalSeminar(int maxOpponents, int maxParticipants) {
|
||||
@ -99,6 +131,90 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return isDeleted();
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
setDeleted(cancelled);
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return this.startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = (Date) startDate.clone();
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
return this.room;
|
||||
}
|
||||
|
||||
public void setRoom(String room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public int getMaxOpponents() {
|
||||
return this.maxOpponents;
|
||||
}
|
||||
|
||||
public void setMaxOpponents(int maxOpponents) {
|
||||
this.maxOpponents = maxOpponents;
|
||||
}
|
||||
|
||||
public int getMaxParticipants() {
|
||||
return this.maxParticipants;
|
||||
}
|
||||
|
||||
public void setMaxParticipants(int maxParticipants) {
|
||||
this.maxParticipants = maxParticipants;
|
||||
}
|
||||
|
||||
public Language getPresentationLanguage() {
|
||||
return this.presentationLanguage;
|
||||
}
|
||||
|
||||
public void setPresentationLanguage(Language presentationLanguage) {
|
||||
this.presentationLanguage = presentationLanguage;
|
||||
}
|
||||
|
||||
public Date getDocumentUploadDate() {
|
||||
return this.documentUploadDate;
|
||||
}
|
||||
|
||||
public void setDocumentUploadDate(Date documentUploadDate) {
|
||||
this.documentUploadDate = documentUploadDate;
|
||||
}
|
||||
|
||||
public String getExtraInfo() {
|
||||
return extraInfo;
|
||||
}
|
||||
|
||||
public void setExtraInfo(String extraInfo) {
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
|
||||
public String getCreationReason() {
|
||||
return this.creationReason;
|
||||
}
|
||||
|
||||
public void setCreationReason(String creationReason) {
|
||||
this.creationReason = creationReason;
|
||||
}
|
||||
|
||||
public Boolean getManualParticipants() {
|
||||
return manualParticipants;
|
||||
}
|
||||
@ -107,21 +223,82 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
||||
this.manualParticipants = manualParticipants;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = (Date) startDate.clone();
|
||||
public FileReference getDocument() {
|
||||
return this.document;
|
||||
}
|
||||
|
||||
public void setDocument(FileReference document) {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Set<FinalSeminarActiveParticipation> getActiveParticipations() {
|
||||
return Collections.unmodifiableSet(activeParticipations);
|
||||
}
|
||||
|
||||
public void setActiveParticipations(Collection<FinalSeminarActiveParticipation> activeParticipations) {
|
||||
this.activeParticipations.clear();
|
||||
this.activeParticipations.addAll(activeParticipations);
|
||||
}
|
||||
|
||||
public Set<FinalSeminarActiveParticipation> getActiveParticipations() {
|
||||
return Collections.unmodifiableSet(activeParticipations);
|
||||
public Set<FinalSeminarOpposition> getOppositions() {
|
||||
return Collections.unmodifiableSet(oppositions);
|
||||
}
|
||||
|
||||
public void setOppositions(Collection<FinalSeminarOpposition> oppositions) {
|
||||
this.oppositions.clear();
|
||||
this.oppositions.addAll(oppositions);
|
||||
}
|
||||
|
||||
public Set<FinalSeminarRespondent> getRespondents() {
|
||||
return this.respondents;
|
||||
}
|
||||
|
||||
public void setRespondents(Set<FinalSeminarRespondent> respondents) {
|
||||
this.respondents = respondents;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof FinalSeminar)) return false;
|
||||
final FinalSeminar other = (FinalSeminar) o;
|
||||
return other.canEqual(this)
|
||||
&& super.equals(o)
|
||||
&& Objects.equals(this.getId(), other.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinalSeminar(id=" + this.getId() + ", project=" + this.getProject() + ", startDate=" +
|
||||
this.getStartDate() + ", room=" + this.getRoom() + ", activeParticipations=" +
|
||||
this.getActiveParticipations() + ", oppositions=" + this.getOppositions() +
|
||||
", respondents=" + this.getRespondents() + ", document=" + this.getDocument() +
|
||||
", documentUploadDate=" + this.getDocumentUploadDate() + ", presentationLanguage=" +
|
||||
this.getPresentationLanguage() + ", maxOpponents=" + this.getMaxOpponents() +
|
||||
", maxParticipants=" + this.getMaxParticipants() + ", creationReason=" +
|
||||
this.getCreationReason() + ")";
|
||||
}
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other Methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminar;
|
||||
}
|
||||
|
||||
public void addActiveParticipant(FinalSeminarActiveParticipation participation) {
|
||||
@ -132,25 +309,62 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
||||
this.activeParticipations.remove(participation);
|
||||
}
|
||||
|
||||
public void setOppositions(Collection<FinalSeminarOpposition> oppositions) {
|
||||
this.oppositions.clear();
|
||||
this.oppositions.addAll(oppositions);
|
||||
public void removeActiveParticipant(User user) {
|
||||
activeParticipations.removeIf(next -> next.getUser().equals(user));
|
||||
}
|
||||
|
||||
public Set<FinalSeminarOpposition> getOppositions() {
|
||||
return Collections.unmodifiableSet(oppositions);
|
||||
public Set<User> getActiveParticipants(){
|
||||
Set<User> activeParticipants = new HashSet<>();
|
||||
for (FinalSeminarActiveParticipation fsap : activeParticipations){
|
||||
activeParticipants.add(fsap.getUser());
|
||||
}
|
||||
return activeParticipants;
|
||||
}
|
||||
|
||||
public Collection<User> getNotGradedActiveParticipations() {
|
||||
return getNotGradedParticipations(activeParticipations);
|
||||
}
|
||||
|
||||
public void addOpposition(FinalSeminarOpposition opposition) {
|
||||
this.oppositions.add(opposition);
|
||||
}
|
||||
|
||||
public void removeOpposition(FinalSeminarOpposition opposition) {
|
||||
this.oppositions.remove(opposition);
|
||||
}
|
||||
|
||||
public Set<User> getOpponents(){
|
||||
Set<User> opponents = new HashSet<>();
|
||||
for (FinalSeminarOpposition fso : oppositions){
|
||||
opponents.add(fso.getUser());
|
||||
}
|
||||
return opponents;
|
||||
}
|
||||
|
||||
public Collection<User> getNotGradedOpponents() {
|
||||
return getNotGradedParticipations(oppositions);
|
||||
}
|
||||
|
||||
public Collection<User> getNotGradedRespondents() {
|
||||
return getNotGradedParticipations(respondents);
|
||||
}
|
||||
|
||||
private Collection<User> getNotGradedParticipations(Set<? extends FinalSeminarParticipation> participations) {
|
||||
List<User> result = new ArrayList<>();
|
||||
for (FinalSeminarParticipation participation : participations) {
|
||||
if(participation.getGrade() == null) {
|
||||
result.add(participation.getUser());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getMinOpponents() {
|
||||
return project.getMinOpponentsOnFinalSeminar();
|
||||
return getProject().getMinOpponentsOnFinalSeminar();
|
||||
}
|
||||
|
||||
public int getMinActiveParticipants() {
|
||||
return project.getMinFinalSeminarActiveParticipation();
|
||||
return getProject().getMinFinalSeminarActiveParticipation();
|
||||
}
|
||||
|
||||
public List<Member> getMembers() {
|
||||
@ -172,177 +386,10 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
||||
}
|
||||
|
||||
public ProjectType getProjectType() {
|
||||
return project.getProjectType();
|
||||
return getProject().getProjectType();
|
||||
}
|
||||
|
||||
public String getProjectTitle() {
|
||||
return project.getTitle();
|
||||
return getProject().getTitle();
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
setDeleted(cancelled);
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return isDeleted();
|
||||
}
|
||||
|
||||
public void removeOpposition(FinalSeminarOpposition opposition) {
|
||||
this.oppositions.remove(opposition);
|
||||
}
|
||||
|
||||
public Collection<User> getNotGradedOpponents() {
|
||||
return getNotGradedParticipations(oppositions);
|
||||
}
|
||||
|
||||
public Collection<User> getNotGradedActiveParticipations() {
|
||||
return getNotGradedParticipations(activeParticipations);
|
||||
}
|
||||
|
||||
public Collection<User> getNotGradedRespondents() {
|
||||
return getNotGradedParticipations(respondents);
|
||||
}
|
||||
|
||||
private Collection<User> getNotGradedParticipations(Set<? extends FinalSeminarParticipation> participations) {
|
||||
List<User> result = new ArrayList<>();
|
||||
for (FinalSeminarParticipation participation : participations) {
|
||||
if(participation.getGrade() == null) {
|
||||
result.add(participation.getUser());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<User> getOpponents(){
|
||||
Set<User> opponents = new HashSet<>();
|
||||
for (FinalSeminarOpposition fso : oppositions){
|
||||
opponents.add(fso.getUser());
|
||||
}
|
||||
return opponents;
|
||||
}
|
||||
|
||||
public Set<User> getActiveParticipants(){
|
||||
Set<User> activeParticipants = new HashSet<>();
|
||||
for (FinalSeminarActiveParticipation fsap : activeParticipations){
|
||||
activeParticipants.add(fsap.getUser());
|
||||
}
|
||||
return activeParticipants;
|
||||
}
|
||||
|
||||
public void removeActiveParticipant(User user) {
|
||||
activeParticipations.removeIf(next -> next.getUser().equals(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return this.startDate;
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
return this.room;
|
||||
}
|
||||
|
||||
public Set<FinalSeminarRespondent> getRespondents() {
|
||||
return this.respondents;
|
||||
}
|
||||
|
||||
public FileReference getDocument() {
|
||||
return this.document;
|
||||
}
|
||||
|
||||
public Date getDocumentUploadDate() {
|
||||
return this.documentUploadDate;
|
||||
}
|
||||
|
||||
public Language getPresentationLanguage() {
|
||||
return this.presentationLanguage;
|
||||
}
|
||||
|
||||
public int getMaxOpponents() {
|
||||
return this.maxOpponents;
|
||||
}
|
||||
|
||||
public int getMaxParticipants() {
|
||||
return this.maxParticipants;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setRoom(String room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public void setRespondents(Set<FinalSeminarRespondent> respondents) {
|
||||
this.respondents = respondents;
|
||||
}
|
||||
|
||||
public void setDocument(FileReference document) {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
public void setDocumentUploadDate(Date documentUploadDate) {
|
||||
this.documentUploadDate = documentUploadDate;
|
||||
}
|
||||
|
||||
public void setPresentationLanguage(Language presentationLanguage) {
|
||||
this.presentationLanguage = presentationLanguage;
|
||||
}
|
||||
|
||||
public void setMaxOpponents(int maxOpponents) {
|
||||
this.maxOpponents = maxOpponents;
|
||||
}
|
||||
|
||||
public void setMaxParticipants(int maxParticipants) {
|
||||
this.maxParticipants = maxParticipants;
|
||||
}
|
||||
|
||||
public void setCreationReason(String creationReason) {
|
||||
this.creationReason = creationReason;
|
||||
}
|
||||
|
||||
public String getExtraInfo() {
|
||||
return extraInfo;
|
||||
}
|
||||
|
||||
public void setExtraInfo(String extraInfo) {
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinalSeminar(id=" + this.getId() + ", project=" + this.getProject() + ", startDate=" + this.getStartDate() + ", room=" + this.getRoom() + ", activeParticipations=" + this.getActiveParticipations() + ", oppositions=" + this.getOppositions() + ", respondents=" + this.getRespondents() + ", document=" + this.getDocument() + ", documentUploadDate=" + this.getDocumentUploadDate() + ", presentationLanguage=" + this.getPresentationLanguage() + ", maxOpponents=" + this.getMaxOpponents() + ", maxParticipants=" + this.getMaxParticipants() + ", creationReason=" + this.getCreationReason() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof FinalSeminar)) return false;
|
||||
final FinalSeminar other = (FinalSeminar) o;
|
||||
return other.canEqual(this)
|
||||
&& super.equals(o)
|
||||
&& Objects.equals(this.getId(), other.getId());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.getId());
|
||||
}
|
||||
|
||||
public String getCreationReason() {
|
||||
return this.creationReason;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package se.su.dsv.scipro.finalseminar;
|
||||
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import se.su.dsv.scipro.project.Project;
|
||||
|
||||
import jakarta.persistence.Cacheable;
|
||||
@ -9,13 +10,20 @@ import jakarta.persistence.Table;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Cacheable(true)
|
||||
@Table(name = "final_seminar_active_participation")
|
||||
@Cacheable(true)
|
||||
public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (final_seminar_active_participation)
|
||||
// referencing other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
private Project project;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
@ -24,6 +32,9 @@ public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -34,13 +45,16 @@ public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
|
||||
&& Objects.equals(this.project, other.project);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminarActiveParticipation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), this.getProject());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminarActiveParticipation;
|
||||
}
|
||||
}
|
||||
|
@ -13,73 +13,90 @@ import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="final_seminar_opposition")
|
||||
public class FinalSeminarOpposition extends FinalSeminarParticipation {
|
||||
public static final int FEEDBACK_LENGTH = 2000;
|
||||
@ManyToOne(optional = false)
|
||||
private Project project;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "opponent_report_reference_id")
|
||||
private FileReference opponentReport;
|
||||
|
||||
@OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "finalSeminarOpposition")
|
||||
private OppositionReport oppositionReport;
|
||||
private static final int FEEDBACK_LENGTH = 2000;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Basic
|
||||
@Column(name = "points")
|
||||
private Integer points;
|
||||
|
||||
@Basic
|
||||
@Column(length = FEEDBACK_LENGTH)
|
||||
@Column(name = "feedback", length = FEEDBACK_LENGTH)
|
||||
private String feedback;
|
||||
|
||||
public ProjectType getProjectType() {
|
||||
return getFinalSeminar().getProject().getProjectType();
|
||||
}
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (final_seminar_opposition) referencing
|
||||
// other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToOne
|
||||
@JoinColumn(name = "opponent_report_file_reference_id", referencedColumnName = "id")
|
||||
private FileReference opponentReport;
|
||||
|
||||
public void setProject(final Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
private Project project;
|
||||
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public FileReference getOpponentReport() {
|
||||
return this.opponentReport;
|
||||
}
|
||||
|
||||
public OppositionReport getOppositionReport() {
|
||||
return this.oppositionReport;
|
||||
}
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of other tables referencing to this table (final_seminar_opposition)
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL,
|
||||
mappedBy = "finalSeminarOpposition")
|
||||
private OppositionReport oppositionReport;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Integer getPoints() {
|
||||
return this.points;
|
||||
}
|
||||
|
||||
public String getFeedback() {
|
||||
return this.feedback;
|
||||
}
|
||||
|
||||
public void setOpponentReport(FileReference opponentReport) {
|
||||
this.opponentReport = opponentReport;
|
||||
}
|
||||
|
||||
public void setOppositionReport(OppositionReport oppositionReport) {
|
||||
this.oppositionReport = oppositionReport;
|
||||
}
|
||||
|
||||
public void setPoints(Integer points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public String getFeedback() {
|
||||
return this.feedback;
|
||||
}
|
||||
|
||||
public void setFeedback(String feedback) {
|
||||
this.feedback = feedback;
|
||||
}
|
||||
|
||||
public FileReference getOpponentReport() {
|
||||
return this.opponentReport;
|
||||
}
|
||||
|
||||
public void setOpponentReport(FileReference opponentReport) {
|
||||
this.opponentReport = opponentReport;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public void setProject(final Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public OppositionReport getOppositionReport() {
|
||||
return this.oppositionReport;
|
||||
}
|
||||
|
||||
public void setOppositionReport(OppositionReport oppositionReport) {
|
||||
this.oppositionReport = oppositionReport;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -90,13 +107,20 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
|
||||
&& Objects.equals(this.getProject(), other.getProject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), this.getProject());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other Methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminarOpposition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), this.getProject());
|
||||
public ProjectType getProjectType() {
|
||||
return getFinalSeminar().getProject().getProjectType();
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,66 @@
|
||||
package se.su.dsv.scipro.finalseminar;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import se.su.dsv.scipro.system.DomainObject;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class FinalSeminarParticipation extends DomainObject {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private User user;
|
||||
@Basic
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "grade")
|
||||
private FinalSeminarGrade grade = null;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in tables whose entity class inherits from
|
||||
// FinalSeminarParticipation class (such as final_seminar_active_participation,
|
||||
// final_seminar_opposition, final_seminar_respondent) referencing other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "final_seminar_id", referencedColumnName = "id")
|
||||
private FinalSeminar finalSeminar;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private FinalSeminarGrade grade = null;
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "user_id", referencedColumnName = "id")
|
||||
private User user;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected FinalSeminarParticipation() {
|
||||
}
|
||||
|
||||
protected FinalSeminarParticipation(User user, FinalSeminar finalSeminar) {
|
||||
this.user = user;
|
||||
this.finalSeminar = finalSeminar;
|
||||
}
|
||||
|
||||
protected FinalSeminarParticipation() {
|
||||
}
|
||||
|
||||
public boolean isApproved() {
|
||||
return grade == FinalSeminarGrade.APPROVED;
|
||||
}
|
||||
|
||||
public boolean hasGrade() {
|
||||
return (grade != null);
|
||||
}
|
||||
|
||||
public void setUser(final User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void setFinalSeminar(final FinalSeminar finalSeminar) {
|
||||
this.finalSeminar = finalSeminar;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public FinalSeminar getFinalSeminar() {
|
||||
return this.finalSeminar;
|
||||
}
|
||||
|
||||
public FinalSeminarGrade getGrade() {
|
||||
return this.grade;
|
||||
}
|
||||
@ -67,6 +69,29 @@ public abstract class FinalSeminarParticipation extends DomainObject {
|
||||
this.grade = grade;
|
||||
}
|
||||
|
||||
public boolean hasGrade() {
|
||||
return (grade != null);
|
||||
}
|
||||
|
||||
public FinalSeminar getFinalSeminar() {
|
||||
return this.finalSeminar;
|
||||
}
|
||||
|
||||
public void setFinalSeminar(final FinalSeminar finalSeminar) {
|
||||
this.finalSeminar = finalSeminar;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public void setUser(final User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -77,12 +102,20 @@ public abstract class FinalSeminarParticipation extends DomainObject {
|
||||
&& Objects.equals(this.getFinalSeminar(), other.getFinalSeminar());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminarParticipation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getUser(), this.getFinalSeminar());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FinalSeminarParticipation;
|
||||
}
|
||||
|
||||
public boolean isApproved() {
|
||||
return grade == FinalSeminarGrade.APPROVED;
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,17 @@ import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Cacheable(true)
|
||||
@Table(name = "final_seminar_respondent")
|
||||
@Cacheable(true)
|
||||
public class FinalSeminarRespondent extends FinalSeminarParticipation {
|
||||
|
||||
protected FinalSeminarRespondent() {
|
||||
}
|
||||
|
||||
public FinalSeminarRespondent(User student, FinalSeminar finalSeminar) {
|
||||
super(student, finalSeminar);
|
||||
}
|
||||
|
||||
protected FinalSeminarRespondent() {
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return getFinalSeminar().getProject();
|
||||
}
|
||||
|
@ -2071,13 +2071,142 @@ create index idx_milestone_phase_template_deleted on milestone_phase_template (d
|
||||
* Step 14: Final Seminar related tables
|
||||
*/
|
||||
|
||||
-- table: final_seminar
|
||||
|
||||
alter table `final_seminar` drop foreign key `FK_rv1p7wl0dnj25saiarmk55yvr`;
|
||||
alter table `final_seminar` drop foreign key `FK_final_seminar_document_reference`;
|
||||
|
||||
alter table `final_seminar` drop key `FK_final_seminar_document_reference`;
|
||||
alter table `final_seminar` drop key `FK_rv1p7wl0dnj25saiarmk55yvr`;
|
||||
alter table `final_seminar` drop key `deleted_index`;
|
||||
alter table `final_seminar` drop key `FK49900D28C1813915`;
|
||||
|
||||
alter table `final_seminar` drop key `UK_rv1p7wl0dnj25saiarmk55yvr`;
|
||||
|
||||
alter table `final_seminar` change `version` `version` int(4) not null default 0 after `last_modified`;
|
||||
alter table `final_seminar` change `deleted` `deleted` tinyint(1) not null after `version`;
|
||||
|
||||
alter table `final_seminar` change `startDate` `start_date` datetime not null after `deleted`;
|
||||
alter table `final_seminar` change `room` `room` varchar(255) not null after start_date;
|
||||
alter table `final_seminar` change `maxOpponents` `max_opponents` int(11) not null after `room`;
|
||||
alter table `final_seminar` change `maxParticipants` `max_participants` int(11) not null after `max_opponents`;
|
||||
alter table `final_seminar` change `presentationLanguage` `presentation_lang` varchar(255) not null after `max_participants`;
|
||||
alter table `final_seminar` change `documentUploadDate` `document_upload_date` datetime default null after `presentation_lang`;
|
||||
alter table `final_seminar` change `extra_info` `extra_info` text default null after `document_upload_date`;
|
||||
alter table `final_seminar` change `creationReason` `creation_reason` mediumtext default null after `extra_info`;
|
||||
alter table `final_seminar` change `manualParticipants` `manual_participants` tinyint(1) not null default 0 after `creation_reason`;
|
||||
alter table `final_seminar` change `project_id` `project_id` bigint(20) not null after `document_reference_id`;
|
||||
|
||||
alter table `final_seminar` rename column `document_reference_id` to `file_reference_id`;
|
||||
|
||||
alter table `final_seminar` add constraint uk_final_seminar_project_id unique(project_id);
|
||||
|
||||
create index idx_final_seminar_deleted on final_seminar (deleted);
|
||||
|
||||
alter table `final_seminar`
|
||||
add constraint fk_final_seminar_file_reference_id
|
||||
foreign key (file_reference_id) references file_reference (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar`
|
||||
add constraint fk_final_seminar_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: final_seminar_active_participation
|
||||
|
||||
alter table `final_seminar_active_participation` drop foreign key `final_seminar_active_participation_user_id`;
|
||||
alter table `final_seminar_active_participation` drop foreign key `FK_mk920fce29yhjgv33wr69fe8a`;
|
||||
alter table `final_seminar_active_participation` drop foreign key `FK_3si3rx7tv6ke9oeiq0hts3lm0`;
|
||||
|
||||
alter table `final_seminar_active_participation` drop key `FK35AB727FF583C69F`;
|
||||
alter table `final_seminar_active_participation` drop key `FK35AB727FC1813915`;
|
||||
alter table `final_seminar_active_participation` drop key `FK_mk920fce29yhjgv33wr69fe8a`;
|
||||
alter table `final_seminar_active_participation` drop key `FK_3si3rx7tv6ke9oeiq0hts3lm0`;
|
||||
alter table `final_seminar_active_participation` drop key `final_seminar_active_participation_user_id`;
|
||||
|
||||
alter table `final_seminar_active_participation` change `version` `version` int(4) not null default 0 after `last_modified`;
|
||||
alter table `final_seminar_active_participation` change `grade` `grade` varchar(20) default null after `version`;
|
||||
|
||||
alter table `final_seminar_active_participation` rename column `finalSeminar_id` to `final_seminar_id`;
|
||||
|
||||
alter table `final_seminar_active_participation`
|
||||
add constraint fk_fsap_final_seminar_id
|
||||
foreign key (final_seminar_id) references final_seminar (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar_active_participation`
|
||||
add constraint fk_fsap_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar_active_participation`
|
||||
add constraint fk_fsap_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: final_seminar_opposition
|
||||
|
||||
alter table `final_seminar_opposition` drop foreign key `FK_62i59u7j6x5ma0iydx9no6m4i`;
|
||||
alter table `final_seminar_opposition` drop foreign key `FK_final_seminar_opposition_report`;
|
||||
alter table `final_seminar_opposition` drop foreign key `FK_hilhyo3tgq89pm27i4pxjaua`;
|
||||
alter table `final_seminar_opposition` drop foreign key `final_seminar_opposition_user_id`;
|
||||
|
||||
alter table `final_seminar_opposition` drop key `FK8CD13581F583C69F`;
|
||||
alter table `final_seminar_opposition` drop key `FK8CD13581C1813915`;
|
||||
alter table `final_seminar_opposition` drop key `FK_62i59u7j6x5ma0iydx9no6m4i`;
|
||||
alter table `final_seminar_opposition` drop key `FK_hilhyo3tgq89pm27i4pxjaua`;
|
||||
alter table `final_seminar_opposition` drop key `final_seminar_opposition_user_id`;
|
||||
alter table `final_seminar_opposition` drop key `FK_final_seminar_opposition_report`;
|
||||
|
||||
alter table `final_seminar_opposition` change `version` `version` int(4) not null default 0 after `last_modified`;
|
||||
alter table `final_seminar_opposition` change `finalSeminar_id` `final_seminar_id` bigint(20) not null after `feedback`;
|
||||
alter table `final_seminar_opposition` change `opponent_report_reference_id`
|
||||
`opponent_report_file_reference_id` bigint(20) default null after `final_seminar_id`;
|
||||
alter table `final_seminar_opposition` change `project_id` `project_id` bigint(20) not null
|
||||
after `opponent_report_file_reference_id`;
|
||||
|
||||
alter table `final_seminar_opposition`
|
||||
add constraint fk_fso_final_seminar_id
|
||||
foreign key (final_seminar_id) references final_seminar (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar_opposition`
|
||||
add constraint fk_fso_opponent_report_file_reference_id
|
||||
foreign key (opponent_report_file_reference_id) references file_reference (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar_opposition`
|
||||
add constraint fk_fso_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar_opposition`
|
||||
add constraint fk_fso_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: final_seminar_respondent
|
||||
|
||||
alter table `final_seminar_respondent` drop foreign key `final_seminar_respondent_user_id`;
|
||||
alter table `final_seminar_respondent` drop foreign key `FK_final_seminar_respondent_id`;
|
||||
|
||||
alter table `final_seminar_respondent` drop key `FK_final_seminar_respondent_id`;
|
||||
alter table `final_seminar_respondent` drop key `final_seminar_respondent_user_id`;
|
||||
|
||||
alter table `final_seminar_respondent` change `version` `version` int(4) not null default 0 after `last_modified`;
|
||||
alter table `final_seminar_respondent` change `grade` `grade` varchar(20) default null after `version`;
|
||||
alter table `final_seminar_respondent` change `finalSeminar_id` `final_seminar_id` bigint(20) not null after `grade`;
|
||||
|
||||
alter table `final_seminar_respondent`
|
||||
add constraint fk_fsr_final_seminar_id
|
||||
foreign key (final_seminar_id) references final_seminar (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `final_seminar_respondent`
|
||||
add constraint fk_fsr_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
|
||||
/*
|
||||
@ -2124,12 +2253,18 @@ order by table_name;
|
||||
|
||||
>>> Show foreign keys
|
||||
|
||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||
from information_schema.key_column_usage
|
||||
where table_schema = 'tozh4728' and table_name = 'peer_request' and constraint_name != 'PRIMARY';
|
||||
-- show foreign keys for a simple table
|
||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||
from information_schema.key_column_usage
|
||||
where table_schema = 'tozh4728' and
|
||||
table_name = 'final_seminar_respondent' and
|
||||
constraint_name != 'PRIMARY';
|
||||
|
||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||
from information_schema.key_column_usage
|
||||
where table_schema = 'tozh4728' and constraint_name != 'PRIMARY' order by constraint_name;
|
||||
-- show foreign keys for all tables
|
||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||
from information_schema.key_column_usage
|
||||
where table_schema = 'tozh4728' and
|
||||
constraint_name != 'PRIMARY'
|
||||
order by constraint_name;
|
||||
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user
Less self describing column name.
document_reference_id
tells you something extra rather than just a genericfile_reference_id
. The referenced table/type is visible from the foreign key/class. Each seminar also has multiple documents related to it so a better name is useful. Especially since the columndocument_upload_date
references some "document" but there is no document file column.