task/3382: Harmonisera tabellnamn #6
@ -294,6 +294,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
|
|||||||
", maxParticipants=" + this.getMaxParticipants() + ", creationReason=" +
|
", maxParticipants=" + this.getMaxParticipants() + ", creationReason=" +
|
||||||
this.getCreationReason() + ")";
|
this.getCreationReason() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// Other Methods
|
// Other Methods
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
@ -14,19 +15,28 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class AbstractCriterion extends DomainObject {
|
public abstract class AbstractCriterion extends DomainObject {
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Basic
|
||||||
@Column(name = "title_sv", nullable = false)
|
@Column(name = "title_sv", nullable = false)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@Basic
|
||||||
@Column(name = "title_en", nullable = false)
|
@Column(name = "title_en", nullable = false)
|
||||||
private String titleEn;
|
private String titleEn;
|
||||||
|
|
||||||
|
@Basic
|
||||||
@Column(name = "sort_order", nullable = false)
|
@Column(name = "sort_order", nullable = false)
|
||||||
private Integer sortOrder;
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
protected AbstractCriterion() {
|
protected AbstractCriterion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +46,9 @@ public abstract class AbstractCriterion extends DomainObject {
|
|||||||
this.sortOrder = sortOrder;
|
this.sortOrder = sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
@ -49,14 +62,13 @@ public abstract class AbstractCriterion extends DomainObject {
|
|||||||
return titleEn;
|
return titleEn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle(Language language) {
|
|
||||||
return language == Language.ENGLISH ? getTitleEn() : getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSortOrder() {
|
public Integer getSortOrder() {
|
||||||
return this.sortOrder;
|
return this.sortOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
@ -70,10 +82,6 @@ public abstract class AbstractCriterion extends DomainObject {
|
|||||||
&& Objects.equals(this.getSortOrder(), other.getSortOrder());
|
&& Objects.equals(this.getSortOrder(), other.getSortOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof AbstractCriterion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.getId(), this.getTitle(), this.getTitleEn(), this.getSortOrder());
|
return Objects.hash(this.getId(), this.getTitle(), this.getTitleEn(), this.getSortOrder());
|
||||||
@ -84,6 +92,20 @@ public abstract class AbstractCriterion extends DomainObject {
|
|||||||
return "AbstractCriterion(id=" + this.getId() + ", title=" + this.getTitle() + ", titleEn=" + this.getTitleEn() + ", sortOrder=" + this.getSortOrder() + ")";
|
return "AbstractCriterion(id=" + this.getId() + ", title=" + this.getTitle() + ", titleEn=" + this.getTitleEn() + ", sortOrder=" + this.getSortOrder() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof AbstractCriterion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(Language language) {
|
||||||
|
return language == Language.ENGLISH ? getTitleEn() : getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Embedded class
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
public static class BySortOrderComparator implements Comparator<AbstractCriterion>, Serializable {
|
public static class BySortOrderComparator implements Comparator<AbstractCriterion>, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public int compare(AbstractCriterion o1, AbstractCriterion o2) {
|
public int compare(AbstractCriterion o1, AbstractCriterion o2) {
|
||||||
|
@ -6,16 +6,23 @@ import jakarta.persistence.CascadeType;
|
|||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.MappedSuperclass;
|
import jakarta.persistence.MappedSuperclass;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class AttachmentReport extends Report {
|
public abstract class AttachmentReport extends Report {
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in table of children class (OppositionReport)
|
||||||
|
// referencing other tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@OneToOne(optional = true, cascade = CascadeType.ALL)
|
@OneToOne(optional = true, cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "attachment_reference_id")
|
@JoinColumn(name = "attachment_file_reference_id", referencedColumnName = "id")
|
||||||
private FileReference attachment;
|
private FileReference attachment;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
public FileReference getAttachment() {
|
public FileReference getAttachment() {
|
||||||
return this.attachment;
|
return this.attachment;
|
||||||
}
|
}
|
||||||
@ -24,6 +31,9 @@ public abstract class AttachmentReport extends Report {
|
|||||||
this.attachment = attachment;
|
this.attachment = attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
@ -34,14 +44,16 @@ public abstract class AttachmentReport extends Report {
|
|||||||
&& Objects.equals(this.attachment, other.attachment);
|
&& Objects.equals(this.attachment, other.attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof AttachmentReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(super.hashCode(), this.attachment);
|
return Objects.hash(super.hashCode(), this.attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof AttachmentReport;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.system.Language;
|
import se.su.dsv.scipro.system.Language;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -8,26 +13,34 @@ import java.util.Objects;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "criterion")
|
@Table(name = "criterion")
|
||||||
public class Criterion extends AbstractCriterion {
|
public class Criterion extends AbstractCriterion {
|
||||||
|
|
||||||
public static final int DESCRIPTION_LENGTH = 2000;
|
public static final int DESCRIPTION_LENGTH = 2000;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
// ----------------------------------------------------------------------------------
|
||||||
private Report report;
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Basic
|
@Basic
|
||||||
@Column
|
@Column(name = "description_sv", length = DESCRIPTION_LENGTH)
|
||||||
private String feedback;
|
|
||||||
|
|
||||||
@Basic
|
|
||||||
@Column(length = DESCRIPTION_LENGTH)
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(length = DESCRIPTION_LENGTH)
|
@Column(name = "description_en", length = DESCRIPTION_LENGTH)
|
||||||
private String descriptionEn;
|
private String descriptionEn;
|
||||||
|
|
||||||
protected Criterion() {
|
@Basic
|
||||||
|
@Column(name = "feedback")
|
||||||
|
private String feedback;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in this table (criterion) referencing other tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name ="report_id", referencedColumnName = "id")
|
||||||
|
private Report report;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
protected Criterion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Criterion(Report report, String title, String titleEn, String description, String descriptionEn, int sortOrder) {
|
Criterion(Report report, String title, String titleEn, String description, String descriptionEn, int sortOrder) {
|
||||||
@ -41,22 +54,9 @@ public class Criterion extends AbstractCriterion {
|
|||||||
this(report, gradingCriterionTemplate.getTitle(), gradingCriterionTemplate.getTitleEn(), gradingCriterionTemplate.getDescription(), gradingCriterionTemplate.getDescriptionEn(), gradingCriterionTemplate.getSortOrder());
|
this(report, gradingCriterionTemplate.getTitle(), gradingCriterionTemplate.getTitleEn(), gradingCriterionTemplate.getDescription(), gradingCriterionTemplate.getDescriptionEn(), gradingCriterionTemplate.getSortOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeedback(final String feedback) {
|
// ----------------------------------------------------------------------------------
|
||||||
this.feedback = feedback;
|
// Properties (Getters and Setters)
|
||||||
}
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
public boolean isFilledOut() {
|
|
||||||
return feedback != null && !feedback.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Report getReport() {
|
|
||||||
return this.report;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFeedback() {
|
|
||||||
return this.feedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
@ -65,10 +65,21 @@ public class Criterion extends AbstractCriterion {
|
|||||||
return this.descriptionEn;
|
return this.descriptionEn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription(Language language) {
|
public String getFeedback() {
|
||||||
return language == Language.ENGLISH ? getDescriptionEn() : getDescription();
|
return this.feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFeedback(final String feedback) {
|
||||||
|
this.feedback = feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Report getReport() {
|
||||||
|
return this.report;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
@ -82,11 +93,6 @@ public class Criterion extends AbstractCriterion {
|
|||||||
&& Objects.equals(this.getDescriptionEn(), other.getDescriptionEn());
|
&& Objects.equals(this.getDescriptionEn(), other.getDescriptionEn());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof Criterion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.getReport(), this.getFeedback(), this.getDescription(), this.getDescriptionEn());
|
return Objects.hash(this.getReport(), this.getFeedback(), this.getDescription(), this.getDescriptionEn());
|
||||||
@ -94,6 +100,24 @@ public class Criterion extends AbstractCriterion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Criterion(report=" + this.getReport() + ", feedback=" + this.getFeedback() + ", description=" + this.getDescription() + ", descriptionEn=" + this.getDescriptionEn() + ")";
|
return "Criterion(report=" + this.getReport() + ", feedback=" + this.getFeedback() +
|
||||||
|
", description=" + this.getDescription() + ", descriptionEn=" +
|
||||||
|
this.getDescriptionEn() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof Criterion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription(Language language) {
|
||||||
|
return language == Language.ENGLISH ? getDescriptionEn() : getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFilledOut() {
|
||||||
|
return feedback != null && !feedback.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.CascadeType;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.finalseminar.FinalSeminarOpposition;
|
import se.su.dsv.scipro.finalseminar.FinalSeminarOpposition;
|
||||||
import se.su.dsv.scipro.system.Language;
|
import se.su.dsv.scipro.system.Language;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -15,56 +22,57 @@ import java.util.stream.Collectors;
|
|||||||
@Table(name = "opposition_report")
|
@Table(name = "opposition_report")
|
||||||
public class OppositionReport extends AttachmentReport {
|
public class OppositionReport extends AttachmentReport {
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Basic
|
||||||
|
@Column(name = "thesis_summary")
|
||||||
|
private String thesisSummary;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in this table (opposition_report) referencing other
|
||||||
|
// tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@OneToOne(optional = false)
|
@OneToOne(optional = false)
|
||||||
|
@JoinColumn(name = "final_seminar_opposition_id", referencedColumnName = "id")
|
||||||
private FinalSeminarOpposition finalSeminarOpposition;
|
private FinalSeminarOpposition finalSeminarOpposition;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of other tables referencing to this table "opposition_report"
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@OneToMany(mappedBy = "report", cascade = {CascadeType.ALL})
|
@OneToMany(mappedBy = "report", cascade = {CascadeType.ALL})
|
||||||
private List<Criterion> oppositionCriteria = new ArrayList<>();
|
private List<Criterion> oppositionCriteria = new ArrayList<>();
|
||||||
|
|
||||||
@Basic
|
// ----------------------------------------------------------------------------------
|
||||||
@Column
|
// Constructors
|
||||||
private String thesisSummary;
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
protected OppositionReport() {
|
protected OppositionReport() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OppositionReport(GradingReportTemplate gradingReportTemplate, FinalSeminarOpposition finalSeminarOpposition) {
|
public OppositionReport(GradingReportTemplate gradingReportTemplate,
|
||||||
|
FinalSeminarOpposition finalSeminarOpposition) {
|
||||||
this.finalSeminarOpposition = finalSeminarOpposition;
|
this.finalSeminarOpposition = finalSeminarOpposition;
|
||||||
createCriteriaFromTemplate(gradingReportTemplate);
|
createCriteriaFromTemplate(gradingReportTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCriteriaFromTemplate(GradingReportTemplate gradingReportTemplate) {
|
// ----------------------------------------------------------------------------------
|
||||||
for (GradingCriterionTemplate template : gradingReportTemplate.getCriteria()) {
|
// Properties (Getters and Setters)
|
||||||
if (template.isProjectCriterion()) {
|
// ----------------------------------------------------------------------------------
|
||||||
oppositionCriteria.add(new Criterion(this, template));
|
public String getThesisSummary() {
|
||||||
}
|
return this.thesisSummary;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Criterion> getCriteria() {
|
public void setThesisSummary(String thesisSummary) {
|
||||||
oppositionCriteria.sort(new AbstractCriterion.BySortOrderComparator());
|
this.thesisSummary = thesisSummary;
|
||||||
return Collections.unmodifiableList(oppositionCriteria);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public FinalSeminarOpposition getFinalSeminarOpposition() {
|
||||||
public boolean isFinished() {
|
return this.finalSeminarOpposition;
|
||||||
if (thesisSummaryIsEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (Criterion criterion : oppositionCriteria) {
|
|
||||||
if (!criterion.isFilledOut()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean thesisSummaryIsEmpty() {
|
|
||||||
return thesisSummary == null || thesisSummary.isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return finalSeminarOpposition.getUser();
|
return finalSeminarOpposition.getUser();
|
||||||
}
|
}
|
||||||
@ -110,15 +118,33 @@ public class OppositionReport extends AttachmentReport {
|
|||||||
return finalSeminarOpposition.getUser().getLastName();
|
return finalSeminarOpposition.getUser().getLastName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FinalSeminarOpposition getFinalSeminarOpposition() {
|
private void createCriteriaFromTemplate(GradingReportTemplate gradingReportTemplate) {
|
||||||
return this.finalSeminarOpposition;
|
for (GradingCriterionTemplate template : gradingReportTemplate.getCriteria()) {
|
||||||
|
if (template.isProjectCriterion()) {
|
||||||
|
oppositionCriteria.add(new Criterion(this, template));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getThesisSummary() {
|
public List<Criterion> getCriteria() {
|
||||||
return this.thesisSummary;
|
oppositionCriteria.sort(new AbstractCriterion.BySortOrderComparator());
|
||||||
|
return Collections.unmodifiableList(oppositionCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThesisSummary(String thesisSummary) {
|
@Override
|
||||||
this.thesisSummary = thesisSummary;
|
public boolean isFinished() {
|
||||||
|
if (thesisSummaryIsEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (Criterion criterion : oppositionCriteria) {
|
||||||
|
if (!criterion.isFilledOut()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean thesisSummaryIsEmpty() {
|
||||||
|
return thesisSummary == null || thesisSummary.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,36 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Inheritance;
|
||||||
|
import jakarta.persistence.InheritanceType;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "report")
|
@Table(name = "report")
|
||||||
@Inheritance(strategy = InheritanceType.JOINED)
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
public abstract class Report extends DomainObject {
|
public abstract class Report extends DomainObject {
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
|
@Column(name = "submitted")
|
||||||
private boolean submitted = false;
|
private boolean submitted = false;
|
||||||
|
|
||||||
public abstract boolean isFinished();
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
public void submit() {
|
// ----------------------------------------------------------------------------------
|
||||||
if (!isFinished()) {
|
|
||||||
throw new IllegalStateException("Report is not finished: you need to score and give feedback to every criteria");
|
|
||||||
}
|
|
||||||
submitted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
if (o == this) return true;
|
|
||||||
if (!(o instanceof Report)) return false;
|
|
||||||
final Report other = (Report) o;
|
|
||||||
return other.canEqual(this)
|
|
||||||
&& Objects.equals(this.id, other.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof Report;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hashCode(this.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
@ -55,4 +43,37 @@ public abstract class Report extends DomainObject {
|
|||||||
public void setSubmitted(boolean submitted) {
|
public void setSubmitted(boolean submitted) {
|
||||||
this.submitted = submitted;
|
this.submitted = submitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof Report)) return false;
|
||||||
|
final Report other = (Report) o;
|
||||||
|
return other.canEqual(this)
|
||||||
|
&& Objects.equals(this.id, other.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof Report;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean isFinished();
|
||||||
|
|
||||||
|
public void submit() {
|
||||||
|
if (!isFinished()) {
|
||||||
|
throw new IllegalStateException("Report is not finished: you need to score and give feedback to every criteria");
|
||||||
|
}
|
||||||
|
submitted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2208,6 +2208,87 @@ alter table `final_seminar_respondent`
|
|||||||
foreign key (user_id) references user (id)
|
foreign key (user_id) references user (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step 14: Report and Criterion related tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- table: report
|
||||||
|
|
||||||
|
alter table `report` change `submitted` `submitted` tinyint(1) not null default 0 after `version`;
|
||||||
|
|
||||||
|
-- table: opposition_report
|
||||||
|
|
||||||
|
alter table `opposition_report` drop foreign key `opposition_report_ibfk_1`;
|
||||||
|
alter table `opposition_report` drop foreign key `FK_opposition_report_seminar_opposition`;
|
||||||
|
alter table `opposition_report` drop foreign key `FK_opposition_report_attachment`;
|
||||||
|
|
||||||
|
alter table `opposition_report` drop key `FK_opposition_report_attachment`;
|
||||||
|
alter table `opposition_report` drop key `FK_opposition_report_seminar_opposition`;
|
||||||
|
|
||||||
|
alter table `opposition_report` drop key `UK_one_report_per_opponent`;
|
||||||
|
|
||||||
|
alter table `opposition_report` change `thesisSummary` `thesis_summary` longtext default null after `id`;
|
||||||
|
|
||||||
|
alter table `opposition_report` change `attachment_reference_id` `attachment_file_reference_id`
|
||||||
|
bigint(20) default null after `thesis_summary`;
|
||||||
|
|
||||||
|
alter table `opposition_report` change `finalSeminarOpposition_id` `final_seminar_opposition_id`
|
||||||
|
bigint(20) not null after `attachment_file_reference_id`;
|
||||||
|
|
||||||
|
alter table `opposition_report` add constraint uk_or_final_seminar_opposition_id
|
||||||
|
unique(final_seminar_opposition_id);
|
||||||
|
|
||||||
|
alter table `opposition_report`
|
||||||
|
add constraint fk_or_id
|
||||||
|
foreign key (id) references report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
alter table `opposition_report`
|
||||||
|
add constraint fk_or_attachment_file_reference_id
|
||||||
|
foreign key (attachment_file_reference_id) references file_reference (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
alter table `opposition_report`
|
||||||
|
add constraint fk_or_final_seminar_opposition_id
|
||||||
|
foreign key (final_seminar_opposition_id) references final_seminar_opposition (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table: criterion
|
||||||
|
|
||||||
|
alter table `criterion` drop foreign key `FK_criterion_report`;
|
||||||
|
|
||||||
|
alter table `criterion` drop key `FK_criterion_report`;
|
||||||
|
|
||||||
|
alter table `criterion` change `title_sv` `title_sv` varchar(255) not null after `version`;
|
||||||
|
alter table `criterion` change `title_en` `title_en` varchar(255) not null default '' after `title_sv`;
|
||||||
|
alter table `criterion` change `description` `description_sv` varchar(2000) default null after `title_en`;
|
||||||
|
alter table `criterion` change `descriptionEn` `description_en` varchar(2000) default null after `description_sv`;
|
||||||
|
alter table `criterion` change `feedback` `feedback` longtext default null after `description_en`;
|
||||||
|
alter table `criterion` change `report_id` `report_id` bigint(20) not null after `sort_order`;
|
||||||
|
|
||||||
|
alter table `criterion`
|
||||||
|
add constraint fk_criterion_report_id
|
||||||
|
foreign key (report_id) references report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- todo: table: GradingCriterionPoint, except foreign key to becoming table grading_criterion
|
||||||
|
|
||||||
|
-- todo: table: GradingCriterion, except foreign key to becoming table grading_report
|
||||||
|
|
||||||
|
-- todo: add foreign key reference from grading_criterion_point to grading_criterion
|
||||||
|
|
||||||
|
-- todo: table: SupervisorGradingReport, except foreign key to becoming table grading_report
|
||||||
|
|
||||||
|
-- todo: table: ReviewerGradingReport, except foreign key to becoming table grading_report
|
||||||
|
|
||||||
|
-- todo: table: GradingReport
|
||||||
|
|
||||||
|
-- todo: add foreign key reference from reviewer_grading_report to grading_report
|
||||||
|
|
||||||
|
-- todo: add foreign key reference from supervisor_grading_report to grading_report
|
||||||
|
|
||||||
|
-- todo: add foreign key reference from grading_criterion to grading_report
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step XX: Many-to-Many tables between project and user.
|
* Step XX: Many-to-Many tables between project and user.
|
||||||
@ -2257,7 +2338,7 @@ order by table_name;
|
|||||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||||
from information_schema.key_column_usage
|
from information_schema.key_column_usage
|
||||||
where table_schema = 'tozh4728' and
|
where table_schema = 'tozh4728' and
|
||||||
table_name = 'final_seminar_respondent' and
|
table_name = 'criterion' and
|
||||||
constraint_name != 'PRIMARY';
|
constraint_name != 'PRIMARY';
|
||||||
|
|
||||||
-- show foreign keys for all tables
|
-- show foreign keys for all tables
|
||||||
@ -2265,6 +2346,11 @@ order by table_name;
|
|||||||
from information_schema.key_column_usage
|
from information_schema.key_column_usage
|
||||||
where table_schema = 'tozh4728' and
|
where table_schema = 'tozh4728' and
|
||||||
constraint_name != 'PRIMARY'
|
constraint_name != 'PRIMARY'
|
||||||
order by constraint_name;
|
order by table_name collate utf8_nopad_bin, constraint_name collate utf8_nopad_bin;
|
||||||
|
|
||||||
|
|
||||||
|
> Show collation;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
Loading…
x
Reference in New Issue
Block a user