task/3382: Harmonisera tabellnamn #6
@ -1,140 +1,165 @@
|
||||
package se.su.dsv.scipro.activityplan;
|
||||
|
||||
import com.querydsl.core.annotations.QueryInit;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import se.su.dsv.scipro.checklist.Checklist;
|
||||
import se.su.dsv.scipro.file.FileReference;
|
||||
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.Cacheable;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
import se.su.dsv.scipro.checklist.Checklist;
|
||||
import se.su.dsv.scipro.file.FileReference;
|
||||
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "activity")
|
||||
@Cacheable(true)
|
||||
public class Activity extends LazyDeletableDomainObject {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
@JoinColumn (name="activityTemplate_id")
|
||||
@QueryInit("project")
|
||||
private ActivityPlan activityPlan;
|
||||
@Basic
|
||||
@Column(name = "title", nullable=false)
|
||||
private String title;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Date date;
|
||||
@Basic
|
||||
@Column(name = "date", nullable=false)
|
||||
private Date date;
|
||||
|
||||
@Column(nullable=false)
|
||||
private String title;
|
||||
|
||||
private String description;
|
||||
|
||||
@OneToOne(optional = true, cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "file_upload_reference_id")
|
||||
private FileReference fileUpload;
|
||||
|
||||
@ManyToOne
|
||||
private Checklist checklist;
|
||||
@Basic
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Basic
|
||||
@Column(name = "editable")
|
||||
private boolean editable = true;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "action")
|
||||
private Action action = Action.NONE;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (activity) referencing other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "activity_plan_id", referencedColumnName = "id")
|
||||
@QueryInit("project")
|
||||
private ActivityPlan activityPlan;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "checklist_id", referencedColumnName = "id")
|
||||
private Checklist checklist;
|
||||
|
||||
@OneToOne(optional = true, cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "file_upload_reference_id", referencedColumnName = "id")
|
||||
private FileReference fileUpload;
|
||||
|
||||
tozh4728 marked this conversation as resolved
Outdated
|
||||
// ----------------------------------------------------------------------------------
|
||||
// constructor
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Activity() {
|
||||
this.title = "";
|
||||
this.description = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Event: "+ getTitle()+"@"+getDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
// ----------------------------------------------------------------------------------
|
||||
// getters and setters
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public ActivityPlan getActivityPlan() {
|
||||
return this.activityPlan;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public FileReference getFileUpload() {
|
||||
return this.fileUpload;
|
||||
}
|
||||
|
||||
public Checklist getChecklist() {
|
||||
return this.checklist;
|
||||
}
|
||||
|
||||
public boolean isEditable() {
|
||||
return this.editable;
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setActivityPlan(ActivityPlan activityPlan) {
|
||||
this.activityPlan = activityPlan;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setFileUpload(FileReference fileUpload) {
|
||||
this.fileUpload = fileUpload;
|
||||
}
|
||||
|
||||
public void setChecklist(Checklist checklist) {
|
||||
this.checklist = checklist;
|
||||
public boolean isEditable() {
|
||||
return this.editable;
|
||||
}
|
||||
|
||||
public void setEditable(boolean editable) {
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public void setAction(Action action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ActivityPlan getActivityPlan() {
|
||||
return this.activityPlan;
|
||||
}
|
||||
|
||||
public void setActivityPlan(ActivityPlan activityPlan) {
|
||||
this.activityPlan = activityPlan;
|
||||
}
|
||||
|
||||
public Checklist getChecklist() {
|
||||
return this.checklist;
|
||||
}
|
||||
|
||||
public void setChecklist(Checklist checklist) {
|
||||
this.checklist = checklist;
|
||||
}
|
||||
|
||||
public FileReference getFileUpload() {
|
||||
return this.fileUpload;
|
||||
}
|
||||
|
||||
public void setFileUpload(FileReference fileUpload) {
|
||||
this.fileUpload = fileUpload;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -144,15 +169,30 @@ public class Activity extends LazyDeletableDomainObject {
|
||||
&& Objects.equals(this.getId(), other.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Event: "+ getTitle()+"@"+getDate();
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof Activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getId());
|
||||
// ----------------------------------------------------------------------------------
|
||||
// static methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
public static IActivityPlan builder(){
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// nested classes
|
||||
// ----------------------------------------------------------------------------------
|
||||
public static class ByDateComparator implements Comparator<Activity>, Serializable {
|
||||
@Override
|
||||
public int compare(Activity o1, Activity o2) {
|
||||
@ -209,10 +249,6 @@ public class Activity extends LazyDeletableDomainObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static IActivityPlan builder(){
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public interface IActivityPlan {
|
||||
IDate activityPlan(ActivityPlan activityPlan);
|
||||
}
|
||||
|
@ -1,67 +1,93 @@
|
||||
package se.su.dsv.scipro.activityplan;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Cacheable;
|
||||
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 se.su.dsv.scipro.project.Project;
|
||||
import se.su.dsv.scipro.system.DomainObject;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@Entity
|
||||
@Table(name =" activity_plan")
|
||||
@Cacheable(true)
|
||||
public class ActivityPlan extends DomainObject {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Basic
|
||||
@Column(name = "start_date")
|
||||
private Date startDate;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (activity_plan) referencing other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToOne(optional=false)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
private Project project;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of other tables referencing to this table "activity_plan"
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToMany(mappedBy= "activityPlan",cascade=CascadeType.PERSIST, orphanRemoval = true)
|
||||
private Set<Activity> activities = new TreeSet<>(new Activity.ByDateComparator());
|
||||
|
||||
@OneToOne(optional=false)
|
||||
private Project project;
|
||||
|
||||
private Date startDate;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// getters and setters
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Set<Activity> getActivities() {
|
||||
return this.activities;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return this.startDate;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setActivities(Set<Activity> activities) {
|
||||
this.activities = activities;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
public Date getStartDate() {
|
||||
return this.startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActivityPlan(id=" + this.getId() + ", activities=" + this.getActivities() + ", project=" + this.getProject() + ", startDate=" + this.getStartDate() + ")";
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Set<Activity> getActivities() {
|
||||
return this.activities;
|
||||
}
|
||||
|
||||
public void setActivities(Set<Activity> activities) {
|
||||
this.activities = activities;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -74,15 +100,31 @@ public class ActivityPlan extends DomainObject {
|
||||
&& Objects.equals(this.getStartDate(), other.getStartDate());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getActivities(), this.getProject(), this.getStartDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActivityPlan(id=" + this.getId() + ", activities=" + this.getActivities() + ", project=" +
|
||||
this.getProject() + ", startDate=" + this.getStartDate() + ")";
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityPlan;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// static methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
public static IProject builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// nested classes
|
||||
// ----------------------------------------------------------------------------------
|
||||
private static class Builder implements IProject, IBuild {
|
||||
private Project project;
|
||||
|
||||
@ -100,10 +142,6 @@ public class ActivityPlan extends DomainObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static IProject builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public interface IProject {
|
||||
IBuild project(Project project);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ import se.su.dsv.scipro.system.DomainObject;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
|
||||
@Entity
|
||||
@Cacheable(true)
|
||||
@Table(name = "activity_plan_template")
|
||||
@Cacheable(true)
|
||||
public class ActivityPlanTemplate extends DomainObject {
|
||||
|
||||
@Id
|
||||
|
@ -1,37 +1,58 @@
|
||||
package se.su.dsv.scipro.firstmeeting;
|
||||
|
||||
import com.querydsl.core.annotations.QueryInit;
|
||||
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.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import se.su.dsv.scipro.activityplan.Activity;
|
||||
import se.su.dsv.scipro.system.DomainObject;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "project_first_meeting")
|
||||
public final class ProjectFirstMeeting extends DomainObject {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@QueryInit("activityPlan.project")
|
||||
@OneToOne(optional = false, cascade = CascadeType.ALL)
|
||||
private Activity activity;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "room")
|
||||
private String room;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (project_first_meeting) referencing
|
||||
// other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToOne(optional = false, cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "activity_id", referencedColumnName = "id")
|
||||
@QueryInit("activityPlan.project")
|
||||
private Activity activity;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// constructor
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected ProjectFirstMeeting() {}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// getters and setters
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return activity.getDate();
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
@ -40,10 +61,6 @@ public final class ProjectFirstMeeting extends DomainObject {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return activity.getDescription();
|
||||
}
|
||||
|
||||
Activity getActivity() {
|
||||
return activity;
|
||||
}
|
||||
@ -51,4 +68,15 @@ public final class ProjectFirstMeeting extends DomainObject {
|
||||
void setActivity(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Date getDate() {
|
||||
return activity.getDate();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return activity.getDescription();
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,49 @@
|
||||
package se.su.dsv.scipro.integration.activityfinalseminar;
|
||||
|
||||
import jakarta.persistence.AttributeOverride;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import se.su.dsv.scipro.activityplan.Activity;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminar;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "activity_final_seminar")
|
||||
class ActivityFinalSeminar {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// embedded JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@EmbeddedId
|
||||
@AttributeOverride(name = "activityId", column = @Column(name = "activity_id"))
|
||||
@AttributeOverride(name = "finalSeminarId", column = @Column(name = "final_seminar_id"))
|
||||
private Id id = new Id();
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (activity_final_seminiar) referencing
|
||||
// other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne
|
||||
@MapsId("activityId")
|
||||
@JoinColumn(name = "activity_id")
|
||||
@JoinColumn(name = "activity_id", referencedColumnName = "id")
|
||||
private Activity activity;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("finalSeminarId")
|
||||
@JoinColumn(name = "final_seminar_id")
|
||||
@JoinColumn(name = "final_seminar_id", referencedColumnName = "id")
|
||||
private FinalSeminar finalSeminar;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// constructor
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected ActivityFinalSeminar() {
|
||||
// JPA
|
||||
}
|
||||
@ -34,6 +53,9 @@ class ActivityFinalSeminar {
|
||||
this.finalSeminar = finalSeminar;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// getters
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Id getId() {
|
||||
return this.id;
|
||||
}
|
||||
@ -46,6 +68,9 @@ class ActivityFinalSeminar {
|
||||
return this.finalSeminar;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -57,10 +82,6 @@ class ActivityFinalSeminar {
|
||||
&& Objects.equals(this.getFinalSeminar(), other.getFinalSeminar());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityFinalSeminar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getActivity(), this.getFinalSeminar());
|
||||
@ -71,6 +92,13 @@ class ActivityFinalSeminar {
|
||||
return "ActivityFinalSeminar(id=" + this.getId() + ", activity=" + this.getActivity() + ", finalSeminar=" + this.getFinalSeminar() + ")";
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityFinalSeminar;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// nested class
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Embeddable
|
||||
static class Id implements Serializable {
|
||||
private Long activityId;
|
||||
|
@ -1,27 +1,44 @@
|
||||
package se.su.dsv.scipro.integration.activityforum;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import se.su.dsv.scipro.activityplan.Activity;
|
||||
import se.su.dsv.scipro.forum.dataobjects.ProjectThread;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "activity_thread")
|
||||
class ActivityThread {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// basic and embedded JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@EmbeddedId
|
||||
private Id id = new Id();
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("threadId")
|
||||
@JoinColumn(name = "project_thread_id")
|
||||
private ProjectThread thread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (activity_thread) referencing other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne
|
||||
@MapsId("activityId")
|
||||
@JoinColumn(name = "activity_id", referencedColumnName = "id")
|
||||
private Activity activity;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("threadId")
|
||||
@JoinColumn(name = "project_thread_id", referencedColumnName = "id")
|
||||
private ProjectThread thread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// constructor
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected ActivityThread() {
|
||||
// JPA
|
||||
}
|
||||
@ -31,6 +48,9 @@ class ActivityThread {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// getters and setters
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Id getId() {
|
||||
return this.id;
|
||||
}
|
||||
@ -43,6 +63,9 @@ class ActivityThread {
|
||||
return this.activity;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -54,10 +77,6 @@ class ActivityThread {
|
||||
&& Objects.equals(this.getActivity(), other.getActivity());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getThread(), this.getActivity());
|
||||
@ -68,6 +87,13 @@ class ActivityThread {
|
||||
return "ActivityThread(id=" + this.getId() + ", thread=" + this.getThread() + ", activity=" + this.getActivity() + ")";
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ActivityThread;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// nested class
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Embeddable
|
||||
static class Id implements Serializable {
|
||||
private Long threadId;
|
||||
|
@ -149,7 +149,7 @@ public class Idea extends DomainObject {
|
||||
private Set<Keyword> keywords = new HashSet<>();
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of other tables referencing this table "idea"
|
||||
// JPA-mappings of other tables referencing to this table "idea"
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
// from table idea_language
|
||||
|
@ -1754,6 +1754,143 @@ alter table `idea_student`
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
/*
|
||||
* Step 11: activity related tables
|
||||
*
|
||||
* Some tables of this group of tables need to be renamed. Because of how foreign keys reference to each other
|
||||
* between them, the order and behavior of how the tables will be fixed looks like stack again.
|
||||
*
|
||||
* 1. Remove references from activity_final_seminar, activity_thread, project_first_meeting to activity,
|
||||
* the fix these three tables, but wait to later before foreign keys are added back to becoming activity table.
|
||||
* 2. Remove reference from Activity to ActivtyPlan, and fix table Activity, without adding back foreign key to
|
||||
* becoming activity_plan table.
|
||||
* 3. Fix ActivityPlan table, rename it to activity_plan.
|
||||
* 4. Add back foreign key reference from activity to activity_plan
|
||||
* 5. Add back foreign key reference from activity_final_seminar, activity_thread, project_first_meeting to
|
||||
* activity table.
|
||||
*/
|
||||
|
||||
-- table: activity_final_seminar, except foreign key to becoming table activity
|
||||
|
||||
alter table `activity_final_seminar` drop foreign key `activity_final_seminar_ibfk_2`;
|
||||
alter table `activity_final_seminar` drop foreign key `activity_final_seminar_ibfk_1`;
|
||||
|
||||
alter table `activity_final_seminar` drop key `activity_id`;
|
||||
|
||||
alter table `activity_final_seminar`
|
||||
add constraint fk_afs_final_seminar_id
|
||||
foreign key (final_seminar_id) references final_seminar (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: activity_thread, except foreign key to becoming table activity
|
||||
|
||||
alter table `activity_thread` drop foreign key `FK_activity_thread_project_thread`;
|
||||
alter table `activity_thread` drop foreign key `FK_activity_thread_activity`;
|
||||
|
||||
alter table `activity_thread` drop key `FK_activity_thread_project_thread`;
|
||||
|
||||
alter table `activity_thread`
|
||||
add constraint fk_activity_thread_project_thread_id
|
||||
foreign key (project_thread_id) references project_thread (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: project_first_meeting, except foreign key to becoming table activity
|
||||
|
||||
alter table `project_first_meeting` drop foreign key `project_first_meeting_ibfk_1`;
|
||||
|
||||
alter table `project_first_meeting` drop key `FK_project_first_meeting_activity`;
|
||||
|
||||
alter table `project_first_meeting` change `room` `room` longtext not null after `version`;
|
||||
|
||||
alter table `project_first_meeting` change `activity_id` `activity_id` bigint(20) not null after `room`;
|
||||
|
||||
-- table: activity
|
||||
|
||||
alter table `Activity` drop foreign key `FK_Activity_file_upload`;
|
||||
alter table `Activity` drop foreign key `FK_Activity_ActivityPlan`;
|
||||
alter table `Activity` drop foreign key `FK_activity_checkList`;
|
||||
|
||||
alter table `Activity` drop key `FK_Activity_file_upload`;
|
||||
alter table `Activity` drop key `activityTemplate_id_index`;
|
||||
alter table `Activity` drop key `deleted_index`;
|
||||
alter table `Activity` drop key `UK_activity_checkList`;
|
||||
|
||||
rename table `Activity` to `activity`;
|
||||
|
||||
alter table `activity` change `title` `title` varchar(500) not null after `deleted`;
|
||||
alter table `activity` change `action` `action` varchar(64) not null default 'none' after `description`;
|
||||
alter table `activity` change `editable` `editable` bit(1) not null default b'1' after `action`;
|
||||
|
||||
alter table `activity` rename column `activityTemplate_id` to `activity_plan_id`;
|
||||
alter table `activity` rename column `file_upload_reference_id` to `file_reference_id`;
|
||||
|
||||
alter table `activity` add constraint uk_activity_checklist_id unique (checklist_id);
|
||||
create index idx_activity_deleted on activity(deleted);
|
||||
|
||||
alter table `activity`
|
||||
add constraint `fk_activity_checklist_id`
|
||||
foreign key (checklist_id) references checklist (id)
|
||||
on delete cascade on update cascade ;
|
||||
|
||||
alter table `activity`
|
||||
add constraint `fk_activity_file_reference_id`
|
||||
foreign key (file_reference_id) references file_reference (id)
|
||||
on delete cascade on update cascade ;
|
||||
|
||||
-- table: ActivityPlan
|
||||
|
||||
alter table `ActivityPlan` drop foreign key `fk_ActivityPlan_project_B`;
|
||||
alter table `ActivityPlan` drop key `project_id`;
|
||||
|
||||
rename table `ActivityPlan` to `activity_plan`;
|
||||
|
||||
alter table `activity_plan` change `version` `version` int(4) not null default 0 after `last_modified`;
|
||||
alter table `activity_plan` change `startDate` `start_date` datetime default null after `version`;
|
||||
|
||||
alter table `activity_plan` add constraint uk_activity_plan_project_id unique (project_id);
|
||||
|
||||
alter table `activity_plan`
|
||||
add constraint `fk_activity_plan_project_id`
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- add foreign key reference from activity to activity_plan
|
||||
|
||||
alter table `activity`
|
||||
add constraint fk_activity_activity_plan_id
|
||||
foreign key (activity_plan_id) references activity_plan (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- Add back all foreign key references to activity
|
||||
|
||||
-- add foreign key reference from project_first_meeting to activity
|
||||
|
||||
alter table `project_first_meeting`
|
||||
add constraint fk_project_first_meeting_activity_id
|
||||
foreign key (activity_id) references activity (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- add foreign key reference from activity_thread to activity
|
||||
|
||||
alter table `activity_thread`
|
||||
add constraint fk_activity_thread_activity_id
|
||||
foreign key (activity_id) references activity (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- add foreign key reference from activity_final_seminar to activity
|
||||
|
||||
alter table `activity_final_seminar`
|
||||
add constraint fk_afs_activity_id
|
||||
foreign key (activity_id) references activity (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
/*
|
||||
* Step 12: XXX related tables
|
||||
*
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -1776,11 +1913,6 @@ alter table `project_user_note`
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Useful SQL
|
||||
|
||||
>>> SQL query for FK-to:
|
||||
|
Loading…
x
Reference in New Issue
Block a user
This feels like a downgrade in terms of documentation from the column name.
file_upload_reference_id
tells you that it is an uploaded file to the activity whilefile_reference_id
conveys no such information.It's renamed to 'upload_file_reference_id', following the same scheme _user_id. "file_reference" is the table name.