task/3382: Harmonisera tabellnamn #6
@ -8,7 +8,109 @@ import jakarta.persistence.MappedSuperclass;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Basic(optional = false)
|
||||
@Column(name = "points_required_to_pass", nullable = false)
|
||||
protected int pointsRequiredToPass;
|
||||
|
||||
@Basic
|
||||
@Column(name = "fx")
|
||||
private boolean fx = true;
|
||||
|
||||
@Basic
|
||||
@Column(name = "flag")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Flag flag;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected AbstractGradingCriterion() {
|
||||
|
||||
}
|
||||
|
||||
protected AbstractGradingCriterion(String title, String titleEn, int sortOrder, int pointsRequiredToPass) {
|
||||
super(title, titleEn, sortOrder);
|
||||
this.pointsRequiredToPass = pointsRequiredToPass;
|
||||
}
|
||||
|
||||
protected AbstractGradingCriterion(String title, String titleEn, Integer sortOrder, int pointsRequiredToPass,
|
||||
Flag flag) {
|
||||
this(title, titleEn, sortOrder, pointsRequiredToPass);
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public int getPointsRequiredToPass() {
|
||||
return this.pointsRequiredToPass;
|
||||
}
|
||||
|
||||
public boolean isFx() {
|
||||
return this.fx;
|
||||
}
|
||||
|
||||
public void setFx(boolean fx) {
|
||||
this.fx = fx;
|
||||
}
|
||||
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(Flag flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof AbstractGradingCriterion)) return false;
|
||||
final AbstractGradingCriterion other = (AbstractGradingCriterion) o;
|
||||
return other.canEqual(this)
|
||||
&& super.equals(o)
|
||||
&& this.getPointsRequiredToPass() == other.getPointsRequiredToPass()
|
||||
&& this.isFx() == other.isFx();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = super.hashCode();
|
||||
result = result * PRIME + this.getPointsRequiredToPass();
|
||||
result = result * PRIME + (this.isFx() ? 79 : 97);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AbstractGradingCriterion(pointsRequiredToPass=" + this.getPointsRequiredToPass() +
|
||||
", fx=" + this.isFx() + ")";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other Methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof AbstractGradingCriterion;
|
||||
}
|
||||
|
||||
public abstract boolean isProjectCriterion();
|
||||
|
||||
public abstract boolean isIndividualCriterion();
|
||||
|
||||
public abstract int getMaxPoints();
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Nested type
|
||||
// ----------------------------------------------------------------------------------
|
||||
public enum Flag {
|
||||
/**
|
||||
* Criterion marked with this flag will add extra functionality related
|
||||
@ -25,91 +127,4 @@ public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
||||
*/
|
||||
OPPOSITION
|
||||
}
|
||||
|
||||
@Basic(optional = false)
|
||||
protected int pointsRequiredToPass;
|
||||
|
||||
@Basic
|
||||
private boolean fx = true;
|
||||
|
||||
@Basic
|
||||
@Column(name = "flag")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Flag flag;
|
||||
|
||||
protected AbstractGradingCriterion() {
|
||||
|
||||
}
|
||||
|
||||
protected AbstractGradingCriterion(String title, String titleEn, int sortOrder, int pointsRequiredToPass) {
|
||||
super(title, titleEn, sortOrder);
|
||||
this.pointsRequiredToPass = pointsRequiredToPass;
|
||||
}
|
||||
|
||||
protected AbstractGradingCriterion(
|
||||
String title,
|
||||
String titleEn,
|
||||
Integer sortOrder,
|
||||
int pointsRequiredToPass,
|
||||
Flag flag)
|
||||
{
|
||||
this(title, titleEn, sortOrder, pointsRequiredToPass);
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public abstract boolean isProjectCriterion();
|
||||
|
||||
public abstract boolean isIndividualCriterion();
|
||||
|
||||
public abstract int getMaxPoints();
|
||||
|
||||
public int getPointsRequiredToPass() {
|
||||
return this.pointsRequiredToPass;
|
||||
}
|
||||
|
||||
public boolean isFx() {
|
||||
return this.fx;
|
||||
}
|
||||
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(Flag flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof AbstractGradingCriterion)) return false;
|
||||
final AbstractGradingCriterion other = (AbstractGradingCriterion) o;
|
||||
return other.canEqual(this)
|
||||
&& super.equals(o)
|
||||
&& this.getPointsRequiredToPass() == other.getPointsRequiredToPass()
|
||||
&& this.isFx() == other.isFx();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof AbstractGradingCriterion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = super.hashCode();
|
||||
result = result * PRIME + this.getPointsRequiredToPass();
|
||||
result = result * PRIME + (this.isFx() ? 79 : 97);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AbstractGradingCriterion(pointsRequiredToPass=" + this.getPointsRequiredToPass() + ", fx=" + this.isFx() + ")";
|
||||
}
|
||||
|
||||
public void setFx(boolean fx) {
|
||||
this.fx = fx;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package se.su.dsv.scipro.report;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
@ -8,18 +9,26 @@ import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "grading_report_template_grade_limits")
|
||||
@Table(name = "grading_report_template_grade_limit")
|
||||
public class GradeLimit {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Basic
|
||||
@Column(name = "grade")
|
||||
private String grade;
|
||||
|
||||
@Basic
|
||||
@Column(name = "lower_limit")
|
||||
private int lowerLimit;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorColumn(name = "type", length = GradingCriterionTemplate.LENGTH)
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@Table(name = "grading_criterion_template")
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name = "type", length = GradingCriterionTemplate.LENGTH)
|
||||
public abstract class GradingCriterionTemplate extends AbstractGradingCriterion {
|
||||
public static final int LENGTH = 64;
|
||||
|
||||
|
@ -1,13 +1,24 @@
|
||||
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.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.TemporalType;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.project.Project;
|
||||
import se.su.dsv.scipro.system.DomainObject;
|
||||
import se.su.dsv.scipro.system.ProjectType;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -19,18 +30,16 @@ import java.util.Objects;
|
||||
@Table(name = "grading_report_template")
|
||||
public class GradingReportTemplate extends DomainObject {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
private ProjectType projectType;
|
||||
|
||||
@OneToMany(mappedBy = "gradingReportTemplate", cascade = {CascadeType.ALL}, orphanRemoval = true)
|
||||
private Collection<GradingCriterionTemplate> criteria = new HashSet<>();
|
||||
|
||||
@Temporal(TemporalType.DATE)
|
||||
@Basic
|
||||
@Column(name = "valid_from")
|
||||
@Temporal(TemporalType.DATE)
|
||||
private LocalDate validFrom;
|
||||
|
||||
@Basic
|
||||
@ -41,10 +50,27 @@ public class GradingReportTemplate extends DomainObject {
|
||||
@Column(name = "failing_grade")
|
||||
private String failingGrade;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (grading_report_template) referencing
|
||||
// other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "project_type_id", referencedColumnName = "id")
|
||||
private ProjectType projectType;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of other tables referencing to this table "grading_report_tempalte"
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToMany(mappedBy = "gradingReportTemplate", cascade = {CascadeType.ALL}, orphanRemoval = true)
|
||||
private Collection<GradingCriterionTemplate> criteria = new HashSet<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "grading_report_template_id")
|
||||
@JoinColumn(name = "grading_report_template_id", referencedColumnName = "id")
|
||||
private Collection<GradeLimit> gradeLimits = new ArrayList<>();
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected GradingReportTemplate() {
|
||||
|
||||
}
|
||||
@ -57,43 +83,9 @@ public class GradingReportTemplate extends DomainObject {
|
||||
this.validFrom = validFrom;
|
||||
}
|
||||
|
||||
public SupervisorGradingReport createSupervisorReport(Project project, User student) {
|
||||
if (!this.projectType.equals(project.getProjectType())) {
|
||||
throw new IllegalArgumentException("Project has a different project class than this template");
|
||||
}
|
||||
return new SupervisorGradingReportFactory().using(criteria).create(project, student);
|
||||
}
|
||||
|
||||
public OppositionReport createOppositionReport(FinalSeminarOpposition finalSeminarOpposition) {
|
||||
return new OppositionReport(this, finalSeminarOpposition);
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addProjectCriterion(String title, String titleEn, int pointsRequiredToPass, List<GradingCriterionPointTemplate> gradingCriterionPointTemplates) {
|
||||
return addProjectCriterion(title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates, null);
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addProjectCriterion(String title, String titleEn, int pointsRequiredToPass, List<GradingCriterionPointTemplate> gradingCriterionPointTemplates, AbstractGradingCriterion.Flag flag) {
|
||||
GradingCriterionTemplate gradingCriterionTemplate = new ProjectGradingCriterionTemplate(this, criteria.size(), title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates);
|
||||
gradingCriterionTemplate.setFlag(flag);
|
||||
criteria.add(gradingCriterionTemplate);
|
||||
return gradingCriterionTemplate;
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addIndividualCriterion(String title, String titleEn, int pointsRequiredToPass, List<GradingCriterionPointTemplate> gradingCriterionPointTemplates) {
|
||||
return addIndividualCriterion(title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates, null);
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addIndividualCriterion(String title, String titleEn, int pointsRequiredToPass, List<GradingCriterionPointTemplate> gradingCriterionPointTemplates, AbstractGradingCriterion.Flag flag) {
|
||||
GradingCriterionTemplate gradingCriterionTemplate = new IndividualGradingCriterionTemplate(this, criteria.size(), title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates);
|
||||
gradingCriterionTemplate.setFlag(flag);
|
||||
criteria.add(gradingCriterionTemplate);
|
||||
return gradingCriterionTemplate;
|
||||
}
|
||||
|
||||
public Collection<GradingCriterionTemplate> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
@ -107,14 +99,6 @@ public class GradingReportTemplate extends DomainObject {
|
||||
this.validFrom = validFrom;
|
||||
}
|
||||
|
||||
public ProjectType getProjectType() {
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setProjectType(ProjectType projectType) {
|
||||
this.projectType = projectType;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
@ -131,6 +115,18 @@ public class GradingReportTemplate extends DomainObject {
|
||||
this.failingGrade = failingGrade;
|
||||
}
|
||||
|
||||
public ProjectType getProjectType() {
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setProjectType(ProjectType projectType) {
|
||||
this.projectType = projectType;
|
||||
}
|
||||
|
||||
public Collection<GradingCriterionTemplate> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Collection<GradeLimit> getGradeLimits() {
|
||||
return gradeLimits;
|
||||
}
|
||||
@ -139,6 +135,9 @@ public class GradingReportTemplate extends DomainObject {
|
||||
this.gradeLimits = gradeLimits;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -148,10 +147,6 @@ public class GradingReportTemplate extends DomainObject {
|
||||
&& Objects.equals(this.id, other.id);
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof GradingReportTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(this.id);
|
||||
@ -159,6 +154,56 @@ public class GradingReportTemplate extends DomainObject {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GradingReportTemplate(id=" + this.id + ", projectType=" + this.projectType + ", validFrom=" + this.validFrom + ")";
|
||||
return "GradingReportTemplate(id=" + this.id + ", projectType=" + this.projectType + ", validFrom=" +
|
||||
this.validFrom + ")";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other Methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
public SupervisorGradingReport createSupervisorReport(Project project, User student) {
|
||||
if (!this.projectType.equals(project.getProjectType())) {
|
||||
throw new IllegalArgumentException("Project has a different project class than this template");
|
||||
}
|
||||
return new SupervisorGradingReportFactory().using(criteria).create(project, student);
|
||||
}
|
||||
|
||||
public OppositionReport createOppositionReport(FinalSeminarOpposition finalSeminarOpposition) {
|
||||
return new OppositionReport(this, finalSeminarOpposition);
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addProjectCriterion(String title, String titleEn, int pointsRequiredToPass,
|
||||
List<GradingCriterionPointTemplate> gradingCriterionPointTemplates) {
|
||||
return addProjectCriterion(title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates, null);
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addProjectCriterion(String title, String titleEn, int pointsRequiredToPass,
|
||||
List<GradingCriterionPointTemplate> gradingCriterionPointTemplates,
|
||||
AbstractGradingCriterion.Flag flag) {
|
||||
GradingCriterionTemplate gradingCriterionTemplate = new ProjectGradingCriterionTemplate(this,
|
||||
criteria.size(), title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates);
|
||||
gradingCriterionTemplate.setFlag(flag);
|
||||
criteria.add(gradingCriterionTemplate);
|
||||
return gradingCriterionTemplate;
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addIndividualCriterion(String title, String titleEn, int pointsRequiredToPass,
|
||||
List<GradingCriterionPointTemplate> gradingCriterionPointTemplates) {
|
||||
return addIndividualCriterion(title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates, null);
|
||||
}
|
||||
|
||||
public GradingCriterionTemplate addIndividualCriterion(String title, String titleEn, int pointsRequiredToPass,
|
||||
List<GradingCriterionPointTemplate> gradingCriterionPointTemplates,
|
||||
AbstractGradingCriterion.Flag flag) {
|
||||
GradingCriterionTemplate gradingCriterionTemplate = new IndividualGradingCriterionTemplate(this,
|
||||
criteria.size(), title, titleEn, pointsRequiredToPass, gradingCriterionPointTemplates);
|
||||
gradingCriterionTemplate.setFlag(flag);
|
||||
criteria.add(gradingCriterionTemplate);
|
||||
return gradingCriterionTemplate;
|
||||
}
|
||||
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof GradingReportTemplate;
|
||||
}
|
||||
}
|
||||
|
@ -808,8 +808,27 @@ alter table `project_type_settings` add constraint uk_project_type_settings_proj
|
||||
|
||||
alter table `grading_report_template` drop foreign key `FK_grading_report_template_projectType`;
|
||||
alter table `grading_report_template` drop key `FK_qovbb9ql33oaxprfr01w7ss9u`;
|
||||
alter table `grading_report_template` drop key `UK_only_one_template_per_date_and_type`;
|
||||
|
||||
alter table `grading_report_template` rename column `projectType_id` to `project_type_id`;
|
||||
alter table `grading_report_template` change `projectType_id` `project_type_id` bigint(20) not null after `failing_grade`;
|
||||
|
||||
alter table `grading_report_template` add constraint uk_grading_report_template_project_type_id_valid_from unique(project_type_id, valid_from);
|
||||
|
||||
-- table: grading_report_template_grade_limits
|
||||
|
||||
alter table `grading_report_template_grade_limits` drop foreign key `FK_grade_limit_grading_report_template `;
|
||||
alter table `grading_report_template_grade_limits` drop key `UK_one_grade_per_template`;
|
||||
|
||||
rename table `grading_report_template_grade_limits` to `grading_report_template_grade_limit`;
|
||||
|
||||
alter table `grading_report_template_grade_limit` change `grading_report_template_id` `grading_report_template_id` bigint(20) default null after `lower_limit`;
|
||||
|
||||
alter table `grading_report_template_grade_limit` add constraint uk_grt_gl_grading_report_template_id_grade unique (grading_report_template_id, grade);
|
||||
|
||||
alter table `grading_report_template_grade_limit`
|
||||
add constraint fk_grt_gl_grading_report_template_id
|
||||
foreign key (grading_report_template_id) references grading_report_template (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
/* >>> START: table grading_criterion_template, GradingCriterion and criterion share same JPA MappedSuperclass, must be handled together. */
|
||||
|
||||
@ -2293,7 +2312,7 @@ alter table `GradingCriterion` change `title_en` `title_en` varchar(255) not nul
|
||||
alter table `GradingCriterion` change `type` `type` varchar(64) not null after `title_en`;
|
||||
alter table `GradingCriterion` change `points_required_to_pass` `points_required_to_pass` int(11) not null after `type`;
|
||||
alter table `GradingCriterion` change `feedback` `feedback` longtext default null after `points`;
|
||||
alter table `GradingCriterion` change `gradingReport_id` `grading_report_id` bigint(20) not null after `fx`;
|
||||
alter table `GradingCriterion` change `gradingReport_id` `grading_report_id` bigint(20) not null after `flag`;
|
||||
|
||||
rename table `GradingCriterion` to `grading_criterion`;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user