task/3382: Harmonisera tabellnamn #6
@ -7,12 +7,20 @@ import jakarta.persistence.MappedSuperclass;
|
|||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Basic
|
||||||
@Column(name = "points_required_to_pass", nullable = false)
|
@Column(name = "points_required_to_pass", nullable = false)
|
||||||
protected int pointsRequiredToPass;
|
protected int pointsRequiredToPass;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
@Column(name = "fx")
|
||||||
private boolean fx = true;
|
private boolean fx = true;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
protected AbstractGradingCriterion() {
|
protected AbstractGradingCriterion() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -22,11 +30,9 @@ public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
|||||||
this.pointsRequiredToPass = pointsRequiredToPass;
|
this.pointsRequiredToPass = pointsRequiredToPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isProjectCriterion();
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
public abstract boolean isIndividualCriterion();
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
public abstract int getMaxPoints();
|
|
||||||
|
|
||||||
public int getPointsRequiredToPass() {
|
public int getPointsRequiredToPass() {
|
||||||
return this.pointsRequiredToPass;
|
return this.pointsRequiredToPass;
|
||||||
@ -36,6 +42,13 @@ public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
|||||||
return this.fx;
|
return this.fx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFx(boolean fx) {
|
||||||
|
this.fx = fx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// 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;
|
||||||
@ -47,11 +60,6 @@ public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
|||||||
&& this.isFx() == other.isFx();
|
&& this.isFx() == other.isFx();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof AbstractGradingCriterion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int PRIME = 59;
|
final int PRIME = 59;
|
||||||
@ -66,7 +74,17 @@ public abstract class AbstractGradingCriterion extends AbstractCriterion {
|
|||||||
return "AbstractGradingCriterion(pointsRequiredToPass=" + this.getPointsRequiredToPass() + ", fx=" + this.isFx() + ")";
|
return "AbstractGradingCriterion(pointsRequiredToPass=" + this.getPointsRequiredToPass() + ", fx=" + this.isFx() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFx(boolean fx) {
|
// ----------------------------------------------------------------------------------
|
||||||
this.fx = fx;
|
// 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();
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,19 @@ import se.su.dsv.scipro.system.DomainObject;
|
|||||||
import se.su.dsv.scipro.system.Language;
|
import se.su.dsv.scipro.system.Language;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class AbstractGradingCriterionPoint extends DomainObject implements Comparable<AbstractGradingCriterionPoint> {
|
public abstract class AbstractGradingCriterionPoint extends DomainObject
|
||||||
|
implements Comparable<AbstractGradingCriterionPoint> {
|
||||||
public static final int DESCRIPTION_LENGTH = 600;
|
public static final int DESCRIPTION_LENGTH = 600;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// 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 = "point")
|
||||||
private Integer point;
|
private Integer point;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@ -30,46 +36,51 @@ public abstract class AbstractGradingCriterionPoint extends DomainObject impleme
|
|||||||
@Column(name = "description_en", length = DESCRIPTION_LENGTH)
|
@Column(name = "description_en", length = DESCRIPTION_LENGTH)
|
||||||
private String descriptionEn;
|
private String descriptionEn;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
public AbstractGradingCriterionPoint() {
|
public AbstractGradingCriterionPoint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPoint() {
|
|
||||||
return this.point;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescriptionEn() {
|
|
||||||
return descriptionEn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription(Language language) {
|
|
||||||
return language == Language.ENGLISH ? getDescriptionEn() : getDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getPoint() {
|
||||||
|
return this.point;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPoint(Integer point) {
|
public void setPoint(Integer point) {
|
||||||
this.point = point;
|
this.point = point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescriptionEn() {
|
||||||
|
return descriptionEn;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDescriptionEn(String descriptionEn) {
|
public void setDescriptionEn(String descriptionEn) {
|
||||||
this.descriptionEn = descriptionEn;
|
this.descriptionEn = descriptionEn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects and Comparable
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (o == this) return true;
|
if (o == this) return true;
|
||||||
@ -83,10 +94,6 @@ public abstract class AbstractGradingCriterionPoint extends DomainObject impleme
|
|||||||
&& Objects.equals(this.getDescriptionEn(), other.getDescriptionEn());
|
&& Objects.equals(this.getDescriptionEn(), other.getDescriptionEn());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof AbstractGradingCriterionPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(super.hashCode(), this.getId(), this.getPoint(), this.getDescription(), this.getDescriptionEn());
|
return Objects.hash(super.hashCode(), this.getId(), this.getPoint(), this.getDescription(), this.getDescriptionEn());
|
||||||
@ -96,4 +103,15 @@ public abstract class AbstractGradingCriterionPoint extends DomainObject impleme
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "AbstractGradingCriterionPoint(id=" + this.getId() + ", point=" + this.getPoint() + ", description=" + this.getDescription() + ", descriptionEn=" + this.getDescriptionEn() + ")";
|
return "AbstractGradingCriterionPoint(id=" + this.getId() + ", point=" + this.getPoint() + ", description=" + this.getDescription() + ", descriptionEn=" + this.getDescriptionEn() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof AbstractGradingCriterionPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription(Language language) {
|
||||||
|
return language == Language.ENGLISH ? getDescriptionEn() : getDescription();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.CascadeType;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.DiscriminatorColumn;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Inheritance;
|
||||||
|
import jakarta.persistence.InheritanceType;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,22 +20,38 @@ import java.util.Objects;
|
|||||||
@Entity
|
@Entity
|
||||||
@DiscriminatorColumn(name = "type")
|
@DiscriminatorColumn(name = "type")
|
||||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||||
|
@Table(name = "grading_criterion")
|
||||||
public abstract class GradingCriterion extends AbstractGradingCriterion {
|
public abstract class GradingCriterion extends AbstractGradingCriterion {
|
||||||
public static final int FEEDBACK_LENGTH = 2000;
|
public static final int FEEDBACK_LENGTH = 2000;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
// ----------------------------------------------------------------------------------
|
||||||
private GradingReport gradingReport;
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@OneToMany(mappedBy = "gradingCriterion", orphanRemoval = true, cascade = CascadeType.PERSIST)
|
|
||||||
private List<GradingCriterionPoint> gradingCriterionPoints = new ArrayList<>();
|
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
@Column(name = "points")
|
||||||
private Integer points;
|
private Integer points;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(length = FEEDBACK_LENGTH)
|
@Column(name = "feedback", length = FEEDBACK_LENGTH)
|
||||||
private String feedback;
|
private String feedback;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in this table (grading_criterion) referencing other
|
||||||
|
// tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "grading_report_id", referencedColumnName = "id")
|
||||||
|
private GradingReport gradingReport;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of other tables referencing to this table "grading_criterion"
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@OneToMany(mappedBy = "gradingCriterion", orphanRemoval = true, cascade = CascadeType.PERSIST)
|
||||||
|
private List<GradingCriterionPoint> gradingCriterionPoints = new ArrayList<>();
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
protected GradingCriterion() {
|
protected GradingCriterion() {
|
||||||
// JPA
|
// JPA
|
||||||
}
|
}
|
||||||
@ -41,6 +68,71 @@ public abstract class GradingCriterion extends AbstractGradingCriterion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
public Integer getPoints() {
|
||||||
|
return this.points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(Integer points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFeedback() {
|
||||||
|
return this.feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeedback(String feedback) {
|
||||||
|
this.feedback = feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GradingCriterionPoint> getGradingCriterionPoints() {
|
||||||
|
return this.gradingCriterionPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GradingReport getGradingReport() {
|
||||||
|
return this.gradingReport;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof GradingCriterion)) return false;
|
||||||
|
final GradingCriterion other = (GradingCriterion) o;
|
||||||
|
return other.canEqual(this)
|
||||||
|
&& super.equals(o)
|
||||||
|
&& Objects.equals(this.getGradingReport(), other.getGradingReport())
|
||||||
|
&& Objects.equals(this.getPoints(), other.getPoints())
|
||||||
|
&& Objects.equals(this.getFeedback(), other.getFeedback());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), this.getGradingReport(), this.getPoints(), this.getFeedback());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GradingCriterion(gradingReport=" + this.getGradingReport() + ", points=" + this.getPoints() +
|
||||||
|
", feedback=" + this.getFeedback() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof GradingCriterion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPassFail() {
|
||||||
|
return getMaxPoints() == 1 && getPointsRequiredToPass() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean meetsMinimumPointRequirement() {
|
public boolean meetsMinimumPointRequirement() {
|
||||||
return Objects.requireNonNullElse(getPoints(), 0) >= getPointsRequiredToPass();
|
return Objects.requireNonNullElse(getPoints(), 0) >= getPointsRequiredToPass();
|
||||||
}
|
}
|
||||||
@ -57,59 +149,4 @@ public abstract class GradingCriterion extends AbstractGradingCriterion {
|
|||||||
public int getMaxPoints() {
|
public int getMaxPoints() {
|
||||||
return Collections.max(gradingCriterionPoints).getPoint();
|
return Collections.max(gradingCriterionPoints).getPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GradingReport getGradingReport() {
|
|
||||||
return this.gradingReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPoints() {
|
|
||||||
return this.points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFeedback() {
|
|
||||||
return this.feedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GradingCriterionPoint> getGradingCriterionPoints() {
|
|
||||||
return this.gradingCriterionPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoints(Integer points) {
|
|
||||||
this.points = points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFeedback(String feedback) {
|
|
||||||
this.feedback = feedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
if (o == this) return true;
|
|
||||||
if (!(o instanceof GradingCriterion)) return false;
|
|
||||||
final GradingCriterion other = (GradingCriterion) o;
|
|
||||||
return other.canEqual(this)
|
|
||||||
&& super.equals(o)
|
|
||||||
&& Objects.equals(this.getGradingReport(), other.getGradingReport())
|
|
||||||
&& Objects.equals(this.getPoints(), other.getPoints())
|
|
||||||
&& Objects.equals(this.getFeedback(), other.getFeedback());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof GradingCriterion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), this.getGradingReport(), this.getPoints(), this.getFeedback());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "GradingCriterion(gradingReport=" + this.getGradingReport() + ", points=" + this.getPoints() + ", feedback=" + this.getFeedback() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPassFail() {
|
|
||||||
return getMaxPoints() == 1 && getPointsRequiredToPass() == 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,39 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "GradingCriterionPoint")
|
@Table(name = "grading_criterion_point")
|
||||||
public class GradingCriterionPoint extends AbstractGradingCriterionPoint {
|
public class GradingCriterionPoint extends AbstractGradingCriterionPoint {
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in this table (grading_criterion_point) referencing other
|
||||||
|
// tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "grading_criterion_id", referencedColumnName = "id")
|
||||||
private GradingCriterion gradingCriterion;
|
private GradingCriterion gradingCriterion;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
public GradingCriterionPoint() {
|
public GradingCriterionPoint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GradingCriterionPoint(
|
public GradingCriterionPoint(final Integer point, final String description,
|
||||||
final Integer point,
|
final String descriptionEn, final GradingCriterion gradingCriterion) {
|
||||||
final String description,
|
|
||||||
final String descriptionEn,
|
|
||||||
final GradingCriterion gradingCriterion)
|
|
||||||
{
|
|
||||||
setPoint(point);
|
setPoint(point);
|
||||||
setDescription(description);
|
setDescription(description);
|
||||||
setDescriptionEn(descriptionEn);
|
setDescriptionEn(descriptionEn);
|
||||||
this.gradingCriterion = gradingCriterion;
|
this.gradingCriterion = gradingCriterion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// ----------------------------------------------------------------------------------
|
||||||
public int compareTo(AbstractGradingCriterionPoint abstractGradingCriterionPoint) {
|
// Properties (Getters and Setters)
|
||||||
return this.getPoint().compareTo(abstractGradingCriterionPoint.getPoint());
|
// ----------------------------------------------------------------------------------
|
||||||
}
|
|
||||||
|
|
||||||
public GradingCriterion getGradingCriterion() {
|
public GradingCriterion getGradingCriterion() {
|
||||||
return this.gradingCriterion;
|
return this.gradingCriterion;
|
||||||
}
|
}
|
||||||
@ -40,9 +42,12 @@ public class GradingCriterionPoint extends AbstractGradingCriterionPoint {
|
|||||||
this.gradingCriterion = gradingCriterion;
|
this.gradingCriterion = gradingCriterion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects and Comparable
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public int compareTo(AbstractGradingCriterionPoint abstractGradingCriterionPoint) {
|
||||||
return "GradingCriterionPoint(gradingCriterion=" + this.getGradingCriterion() + ")";
|
return this.getPoint().compareTo(abstractGradingCriterionPoint.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,13 +60,22 @@ public class GradingCriterionPoint extends AbstractGradingCriterionPoint {
|
|||||||
&& Objects.equals(this.getGradingCriterion(), other.getGradingCriterion());
|
&& Objects.equals(this.getGradingCriterion(), other.getGradingCriterion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(this.getGradingCriterion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GradingCriterionPoint(gradingCriterion=" + this.getGradingCriterion() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
protected boolean canEqual(final Object other) {
|
protected boolean canEqual(final Object other) {
|
||||||
return other instanceof GradingCriterionPoint;
|
return other instanceof GradingCriterionPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hashCode(this.getGradingCriterion());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
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.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
import se.su.dsv.scipro.project.Project;
|
import se.su.dsv.scipro.project.Project;
|
||||||
import se.su.dsv.scipro.system.Language;
|
import se.su.dsv.scipro.system.Language;
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -13,6 +21,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name = "grading_report")
|
||||||
public abstract class GradingReport extends Report {
|
public abstract class GradingReport extends Report {
|
||||||
|
|
||||||
public enum Grade {
|
public enum Grade {
|
||||||
@ -21,40 +30,51 @@ public abstract class GradingReport extends Report {
|
|||||||
|
|
||||||
public enum State { INITIAL, REVIEWING, FINALIZED }
|
public enum State { INITIAL, REVIEWING, FINALIZED }
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Basic
|
||||||
|
@Column(name = "state")
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private State state = State.INITIAL;
|
private State state = State.INITIAL;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
|
||||||
private Project project;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "gradingReport", cascade = {CascadeType.ALL})
|
|
||||||
private List<GradingCriterion> gradingCriteria = new ArrayList<>();
|
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "date_submitted_to_examiner")
|
@Column(name = "date_submitted_to_examiner")
|
||||||
private Instant dateSubmittedToExaminer;
|
private Instant dateSubmittedToExaminer;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in this table (grading_report) referencing other
|
||||||
|
// tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
private Project project;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of other tables referencing to this table "grading_report"
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@OneToMany(mappedBy = "gradingReport", cascade = {CascadeType.ALL})
|
||||||
|
private List<GradingCriterion> gradingCriteria = new ArrayList<>();
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
protected GradingReport() {
|
protected GradingReport() {
|
||||||
// JPA
|
// JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submit() {
|
|
||||||
super.submit();
|
|
||||||
setState(State.FINALIZED);
|
|
||||||
setDateSubmittedToExaminer(Instant.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Project getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
GradingReport(Project project) {
|
GradingReport(Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addCriterion(GradingCriterion criterion) {
|
// ----------------------------------------------------------------------------------
|
||||||
gradingCriteria.add(criterion);
|
// Properties (Getters and Setters)
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(final State state) {
|
||||||
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getDateSubmittedToExaminer(){
|
public Instant getDateSubmittedToExaminer(){
|
||||||
@ -65,12 +85,8 @@ public abstract class GradingReport extends Report {
|
|||||||
this.dateSubmittedToExaminer = dateSubmittedToExaminer;
|
this.dateSubmittedToExaminer = dateSubmittedToExaminer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public Project getProject() {
|
||||||
return state;
|
return project;
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(final State state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GradingCriterion> getGradingCriteria() {
|
public List<GradingCriterion> getGradingCriteria() {
|
||||||
@ -78,6 +94,21 @@ public abstract class GradingReport extends Report {
|
|||||||
return Collections.unmodifiableList(gradingCriteria);
|
return Collections.unmodifiableList(gradingCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Methods Common To All Objects
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GradingReport(state=" + this.getState() + ", project=" + this.getProject() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
void addCriterion(GradingCriterion criterion) {
|
||||||
|
gradingCriteria.add(criterion);
|
||||||
|
}
|
||||||
|
|
||||||
public String getProjectTitle() {
|
public String getProjectTitle() {
|
||||||
return project.getTitle();
|
return project.getTitle();
|
||||||
}
|
}
|
||||||
@ -106,7 +137,9 @@ public abstract class GradingReport extends Report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public void submit() {
|
||||||
return "GradingReport(state=" + this.getState() + ", project=" + this.getProject() + ")";
|
super.submit();
|
||||||
|
setState(State.FINALIZED);
|
||||||
|
setDateSubmittedToExaminer(Instant.now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
package se.su.dsv.scipro.report;
|
package se.su.dsv.scipro.report;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import se.su.dsv.scipro.project.Project;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import se.su.dsv.scipro.project.Project;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name = "supervisor_grading_report")
|
||||||
public class SupervisorGradingReport extends GradingReport {
|
public class SupervisorGradingReport extends GradingReport {
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SupervisorGradingReport.class);
|
// Basic JPA-mappings
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
@ManyToOne(optional = false)
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "rejection_comment")
|
@Column(name = "rejection_comment")
|
||||||
private String rejectionComment;
|
private String rejectionComment;
|
||||||
@ -33,6 +31,17 @@ public class SupervisorGradingReport extends GradingReport {
|
|||||||
@Column(name = "motivation")
|
@Column(name = "motivation")
|
||||||
private String motivation;
|
private String motivation;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// JPA-mappings of foreign keys in this table (grading_criterion) referencing other
|
||||||
|
// tables.
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "user_id", referencedColumnName = "id")
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
protected SupervisorGradingReport() {
|
protected SupervisorGradingReport() {
|
||||||
// JPA
|
// JPA
|
||||||
}
|
}
|
||||||
@ -42,6 +51,40 @@ public class SupervisorGradingReport extends GradingReport {
|
|||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Properties (Getters and Setters)
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
public User getUser() {
|
||||||
|
return this.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRejectionComment() {
|
||||||
|
return rejectionComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRejectionComment(String rejectionComment) {
|
||||||
|
this.rejectionComment = rejectionComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRejectionCommentFeedback() {
|
||||||
|
return rejectionCommentFeedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRejectionCommentFeedback(String rejectionCommentFeedback) {
|
||||||
|
this.rejectionCommentFeedback = rejectionCommentFeedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMotivation() {
|
||||||
|
return motivation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMotivation(String motivation) {
|
||||||
|
this.motivation = motivation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
|
// Other Methods
|
||||||
|
// ----------------------------------------------------------------------------------
|
||||||
public List<GradingCriterion> getProjectCriteria() {
|
public List<GradingCriterion> getProjectCriteria() {
|
||||||
List<GradingCriterion> result = new ArrayList<>();
|
List<GradingCriterion> result = new ArrayList<>();
|
||||||
for (GradingCriterion criterion : getGradingCriteria()) {
|
for (GradingCriterion criterion : getGradingCriteria()) {
|
||||||
@ -82,34 +125,6 @@ public class SupervisorGradingReport extends GradingReport {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser() {
|
|
||||||
return this.user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRejectionComment() {
|
|
||||||
return rejectionComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRejectionComment(String rejectionComment) {
|
|
||||||
this.rejectionComment = rejectionComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRejectionCommentFeedback() {
|
|
||||||
return rejectionCommentFeedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRejectionCommentFeedback(String rejectionCommentFeedback) {
|
|
||||||
this.rejectionCommentFeedback = rejectionCommentFeedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMotivation() {
|
|
||||||
return motivation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMotivation(String motivation) {
|
|
||||||
this.motivation = motivation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasProvidedOverallMotivation() {
|
public boolean hasProvidedOverallMotivation() {
|
||||||
return getMotivation() != null && !getMotivation().isBlank();
|
return getMotivation() != null && !getMotivation().isBlank();
|
||||||
}
|
}
|
||||||
|
@ -2271,24 +2271,112 @@ alter table `criterion`
|
|||||||
foreign key (report_id) references report (id)
|
foreign key (report_id) references report (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
-- todo: table: GradingCriterionPoint, except foreign key to becoming table grading_criterion
|
-- table: GradingCriterionPoint, except foreign key to becoming table grading_criterion
|
||||||
|
|
||||||
-- todo: table: GradingCriterion, except foreign key to becoming table grading_report
|
alter table `GradingCriterionPoint` drop foreign key `FK_GradingCriterion_id`;
|
||||||
|
|
||||||
-- todo: add foreign key reference from grading_criterion_point to grading_criterion
|
alter table `GradingCriterionPoint` drop key `FK_GradingCriterion_id`;
|
||||||
|
|
||||||
-- todo: table: SupervisorGradingReport, except foreign key to becoming table grading_report
|
alter table `GradingCriterionPoint` change `GradingCriterion_id` `grading_criterion_id` bigint(20) not null
|
||||||
|
after `description_en`;
|
||||||
|
|
||||||
-- todo: table: ReviewerGradingReport, except foreign key to becoming table grading_report
|
rename table `GradingCriterionPoint` to `grading_criterion_point`;
|
||||||
|
|
||||||
-- todo: table: GradingReport
|
-- table: GradingCriterion, except foreign key to becoming table grading_report
|
||||||
|
|
||||||
-- todo: add foreign key reference from reviewer_grading_report to grading_report
|
alter table `GradingCriterion` drop foreign key `FK_k2ynx2lcpdl969alj5nt3f7xx`;
|
||||||
|
|
||||||
-- todo: add foreign key reference from supervisor_grading_report to grading_report
|
alter table `GradingCriterion` drop key `FK_k2ynx2lcpdl969alj5nt3f7xx`;
|
||||||
|
|
||||||
-- todo: add foreign key reference from grading_criterion to grading_report
|
alter table `GradingCriterion` change `title_sv` `title_sv` varchar(255) not null after `version`;
|
||||||
|
alter table `GradingCriterion` change `title_en` `title_en` varchar(255) not null default '' after `title_sv`;
|
||||||
|
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`;
|
||||||
|
|
||||||
|
rename table `GradingCriterion` to `grading_criterion`;
|
||||||
|
|
||||||
|
alter table `grading_criterion`
|
||||||
|
add constraint fk_grading_criterion_grading_report_id
|
||||||
|
foreign key (grading_report_id) references grading_report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- add foreign key reference from grading_criterion_point to grading_criterion
|
||||||
|
|
||||||
|
alter table `grading_criterion_point`
|
||||||
|
add constraint fk_gcp_grading_criterion_id
|
||||||
|
foreign key (grading_criterion_id) references grading_criterion (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table: SupervisorGradingReport, except foreign key to becoming table grading_report
|
||||||
|
|
||||||
|
alter table `SupervisorGradingReport` drop foreign key `supervisor_grading_report_user_id`;
|
||||||
|
alter table `SupervisorGradingReport` drop foreign key `FK_cwxdypciob8dmndx5elwi3fe5`;
|
||||||
|
|
||||||
|
alter table `SupervisorGradingReport` drop key `supervisor_grading_report_user_id`;
|
||||||
|
alter table `SupervisorGradingReport` drop key `FK_cwxdypciob8dmndx5elwi3fe5`;
|
||||||
|
|
||||||
|
rename table `SupervisorGradingReport` to `supervisor_grading_report`;
|
||||||
|
|
||||||
|
alter table `supervisor_grading_report`
|
||||||
|
add constraint fk_sgr_user_id
|
||||||
|
foreign key (user_id) references user (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table: ReviewerGradingReport, except foreign key to becoming table grading_report
|
||||||
|
|
||||||
|
alter table `ReviewerGradingReport` drop foreign key `FK_axsaeqbamfc41dhih1s62g998`;
|
||||||
|
|
||||||
|
alter table `ReviewerGradingReport` drop key `FK_axsaeqbamfc41dhih1s62g998`;
|
||||||
|
|
||||||
|
rename table `ReviewerGradingReport` to `reviewer_grading_report`;
|
||||||
|
|
||||||
|
-- table: GradingReport
|
||||||
|
|
||||||
|
alter table `GradingReport` drop foreign key `GradingReport_ibfk_1`;
|
||||||
|
alter table `GradingReport` drop foreign key `FK_6ygpk1qq218jgwuuyx0bp6vui`;
|
||||||
|
|
||||||
|
alter table `GradingReport` drop key `FK_6ygpk1qq218jgwuuyx0bp6vui`;
|
||||||
|
|
||||||
|
rename table `GradingReport` to `grading_report`;
|
||||||
|
|
||||||
|
alter table `grading_report`
|
||||||
|
add constraint fk_grading_report_id
|
||||||
|
foreign key (id) references report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
alter table `grading_report`
|
||||||
|
add constraint fk_grading_report_project_id
|
||||||
|
foreign key (project_id) references project (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- add foreign key reference from reviewer_grading_report to grading_report
|
||||||
|
|
||||||
|
alter table `reviewer_grading_report`
|
||||||
|
add constraint fk_reviewer_grading_report_id
|
||||||
|
foreign key (id) references grading_report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- add foreign key reference from supervisor_grading_report to grading_report
|
||||||
|
|
||||||
|
alter table `supervisor_grading_report`
|
||||||
|
add constraint fk_sgr_id
|
||||||
|
foreign key (id) references grading_report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- add foreign key reference from grading_criterion to grading_report
|
||||||
|
|
||||||
|
alter table `grading_criterion`
|
||||||
|
add constraint fk_grading_criterion_grading_report_id
|
||||||
|
foreign key (grading_report_id) references grading_report (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step 15: project and related tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- todo:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step XX: Many-to-Many tables between project and user.
|
* Step XX: Many-to-Many tables between project and user.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user