task/3382: Harmonisera tabellnamn #6

Merged
ansv7779 merged 104 commits from task/3382 into develop 2024-11-12 13:33:44 +01:00
8 changed files with 556 additions and 211 deletions
Showing only changes of commit b052988839 - Show all commits

View File

@ -1,6 +1,16 @@
package se.su.dsv.scipro.match;
import jakarta.persistence.*;
import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable;
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 java.io.Serializable;
import java.util.Date;
import java.util.Objects;
@ -9,72 +19,92 @@ import java.util.Objects;
@Table(name = "idea_first_meeting")
@Cacheable(true)
public class FirstMeeting implements Serializable {
public static final int LENGTH = 1024;
private static final int LENGTH = 1024;
// ----------------------------------------------------------------------------------
// basic JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Basic(optional = false)
private Date firstMeetingDate;
@Column(nullable = false, length = LENGTH)
private String room;
@Column(nullable = true, length = LENGTH)
@Basic
@Column(name = "description", nullable = true, length = LENGTH)
private String description;
@Basic(optional = false)
@Column(name = "first_meeting_date")
private Date firstMeetingDate;
@Basic
@Column(name = "room", nullable = false, length = LENGTH)
private String room;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (idea_first_meeting) referencing other
// tables.
// ----------------------------------------------------------------------------------
@OneToOne(optional = false)
@JoinColumn(name = "idea_id", referencedColumnName = "id")
private Idea idea;
public FirstMeeting() {
}
// ----------------------------------------------------------------------------------
// constructors
// ----------------------------------------------------------------------------------
public FirstMeeting() { }
public FirstMeeting(Date firstMeetingDate, Idea idea) {
this.firstMeetingDate = firstMeetingDate;
this.idea = idea;
}
// ----------------------------------------------------------------------------------
// getters and setters
// ----------------------------------------------------------------------------------
public Long getId() {
return this.id;
}
public Date getFirstMeetingDate() {
return this.firstMeetingDate;
}
public String getRoom() {
return this.room;
}
public String getDescription() {
return this.description;
}
public Idea getIdea() {
return this.idea;
}
public void setId(Long id) {
this.id = id;
}
public void setFirstMeetingDate(Date firstMeetingDate) {
this.firstMeetingDate = firstMeetingDate;
}
public void setRoom(String room) {
this.room = room;
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getFirstMeetingDate() {
return this.firstMeetingDate;
}
public void setFirstMeetingDate(Date firstMeetingDate) {
this.firstMeetingDate = firstMeetingDate;
}
public String getRoom() {
return this.room;
}
public void setRoom(String room) {
this.room = room;
}
public Idea getIdea() {
return this.idea;
}
public void setIdea(Idea idea) {
this.idea = idea;
}
// ----------------------------------------------------------------------------------
// other methods
// ----------------------------------------------------------------------------------
@Override
public boolean equals(final Object o) {
if (o == this) return true;
@ -94,11 +124,13 @@ public class FirstMeeting implements Serializable {
@Override
public int hashCode() {
return Objects.hash(this.getId(), this.getFirstMeetingDate(), this.getRoom(), this.getDescription(), this.getIdea());
return Objects.hash(this.getId(), this.getFirstMeetingDate(), this.getRoom(), this.getDescription(),
this.getIdea());
}
@Override
public String toString() {
return "FirstMeeting(id=" + this.getId() + ", firstMeetingDate=" + this.getFirstMeetingDate() + ", room=" + this.getRoom() + ", description=" + this.getDescription() + ", idea=" + this.getIdea() + ")";
return "FirstMeeting(id=" + this.getId() + ", firstMeetingDate=" + this.getFirstMeetingDate() + ", room=" +
this.getRoom() + ", description=" + this.getDescription() + ", idea=" + this.getIdea() + ")";
}
}

View File

@ -50,96 +50,137 @@ import java.util.stream.Collectors;
@Table(name = "idea")
@Cacheable(true)
public class Idea extends DomainObject {
private static final int DESCRIPTION_LENGTH = 4000;
private static final int PREREQUISITES_LENGTH = 4000;
private static final int TITLE_LENGTH = 1024;
public static final int DESCRIPTION_LENGTH = 4000;
public static final int PREREQUISITES_LENGTH = 4000;
public static final int TITLE_LENGTH = 1024;
// ----------------------------------------------------------------------------------
// basic and embedded JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Basic
@Column(nullable = true, length = DESCRIPTION_LENGTH)
private String description;
@Basic
@Column(nullable = true, length = PREREQUISITES_LENGTH)
private String prerequisites;
@Basic
@Column(nullable = false, length = TITLE_LENGTH)
private String title;
@Basic
@Enumerated(EnumType.STRING)
private Type type;
@Basic
@Column(name = "published")
private boolean published = true;
@Enumerated(EnumType.STRING)
@Column(name = "cached_status")
private Status cachedStatus;
@Basic
@Column(name = "inactive")
private boolean inactive = false;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "practicalHow", column = @Column(name = "practical_how", insertable = false, updatable = false)),
@AttributeOverride(name = "theoryHow", column = @Column(name = "theory_how", insertable = false, updatable = false)),
@AttributeOverride(name = "what", column = @Column(name = "what", insertable = false, updatable = false)),
@AttributeOverride(name = "why", column = @Column(name = "why", insertable = false, updatable = false)),
@AttributeOverride(name = "literature", column = @Column(name = "literature", insertable = false, updatable = false))
})
private Watson watson;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "literature", column = @Column(name = "literature", insertable = false, updatable = false)),
@AttributeOverride(name = "background", column = @Column(name = "background", insertable = false, updatable = false)),
@AttributeOverride(name = "problem", column = @Column(name = "problem", insertable = false, updatable = false)),
@AttributeOverride(name = "method", column = @Column(name = "method", insertable = false, updatable = false)),
@AttributeOverride(name = "interests", column = @Column(name = "interests", insertable = false, updatable = false))
})
private TholanderBox tholanderBox = new TholanderBox();
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (idea) referencing other tables.
// ----------------------------------------------------------------------------------
@ManyToOne(optional = true)
@JoinColumn(name = "application_period_id", referencedColumnName = "id")
private ApplicationPeriod applicationPeriod;
@ManyToOne(optional = false)
@JoinColumn(name = "creator_user_id", referencedColumnName = "id")
private User creator;
@OneToOne(optional = true, cascade = CascadeType.ALL)
@JoinColumn(name = "match_id", referencedColumnName = "id")
@QueryInit({"supervisor.user", "supervisor.unit"})
private Match match;
@OneToOne
@JoinColumn(name = "project_id", referencedColumnName = "id")
private Project project;
@ManyToOne(optional = false)
@JoinColumn(name = "project_type_id", referencedColumnName = "id")
private ProjectType projectType;
@Enumerated(EnumType.STRING)
private Type type;
@ManyToOne(optional = false)
private User creator;
@Column(nullable = true, length = DESCRIPTION_LENGTH)
private String description;
@Column(nullable = true, length = PREREQUISITES_LENGTH)
private String prerequisites;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "idea", cascade = CascadeType.ALL, orphanRemoval = true)
@QueryInit({"user", "program"})
private Set<IdeaParticipation> ideaParticipations = new HashSet<>();
@ManyToOne(optional = true)
@JoinColumn(name = "application_period_id", referencedColumnName = "id")
private ApplicationPeriod applicationPeriod;
@Column(nullable = false, length = TITLE_LENGTH)
private String title;
@ManyToOne(optional = true)
@JoinColumn(name = "research_area_id", referencedColumnName = "id")
private ResearchArea researchArea;
@ElementCollection
@CollectionTable(name = "idea_language")
@Column(name = "language")
@Enumerated(EnumType.STRING)
private Set<Language> languages = EnumSet.noneOf(Language.class);
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "practicalHow", column = @Column(insertable = false, updatable = false)),
@AttributeOverride(name = "literature", column = @Column(insertable = false, updatable = false)),
@AttributeOverride(name = "theoryHow", column = @Column(insertable = false, updatable = false)),
@AttributeOverride(name = "why", column = @Column(insertable = false, updatable = false)),
@AttributeOverride(name = "what", column = @Column(insertable = false, updatable = false))
})
private Watson watson;
@Embedded
private TholanderBox tholanderBox = new TholanderBox();
// ----------------------------------------------------------------------------------
// @ManyToMany JPA-mappings
// ----------------------------------------------------------------------------------
// many-to-many from table "keyword" through table "idea_keyword"
@ManyToMany
@JoinTable(name="idea_keyword",
joinColumns = @JoinColumn(name = "idea_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "keyword_id", referencedColumnName = "id"))
private Set<Keyword> keywords = new HashSet<>();
@OneToOne
private Project project;
// ----------------------------------------------------------------------------------
// JPA-mappings of other tables referencing this table "idea"
// ----------------------------------------------------------------------------------
@OneToOne(mappedBy = "idea", orphanRemoval = true, optional = true)
private FirstMeeting firstMeeting;
// from table idea_language
@ElementCollection
@CollectionTable(name = "idea_language",
joinColumns = @JoinColumn(name = "idea_id", referencedColumnName = "id"))
@Column(name = "language")
@Enumerated(EnumType.STRING)
private Set<Language> languages = EnumSet.noneOf(Language.class);
// from table idea_export
@OneToMany(mappedBy = "idea", cascade = CascadeType.ALL)
private List<IdeaExport> exports = new ArrayList<>();
// from table idea_student
@OneToMany(fetch = FetchType.LAZY, mappedBy = "idea", cascade = CascadeType.ALL, orphanRemoval = true)
@QueryInit({"user", "program"})
private Set<IdeaParticipation> ideaParticipations = new HashSet<>();
// from table "idea_match"
@OneToMany(fetch = FetchType.LAZY, mappedBy = "idea", cascade = CascadeType.ALL)
@OrderBy("dateCreated DESC")
private List<Match> matchHistory = new ArrayList<>();
@OneToOne(optional = true, cascade = CascadeType.ALL)
@QueryInit({"supervisor.user", "supervisor.unit"})
private Match match;
@Column(name = "published")
private boolean published = true;
@OneToMany(mappedBy = "idea", cascade = CascadeType.ALL)
private List<IdeaExport> exports = new ArrayList<>();
@Enumerated(EnumType.STRING)
private Status cachedStatus;
@Basic
private boolean inactive = false;
// from table "idea_first_meeting"
@OneToOne(mappedBy = "idea", orphanRemoval = true, optional = true)
private FirstMeeting firstMeeting;
// ----------------------------------------------------------------------------------
// methods...
// ----------------------------------------------------------------------------------
public Idea copy(User supervisor) {
Idea copy = new Idea();
copy.projectType = this.projectType;
@ -490,7 +531,9 @@ public class Idea extends DomainObject {
public String toString() {
return "Student idea";
}
}, SUPERVISOR {
},
SUPERVISOR {
@Override
public String toString() {
return "Supervisor idea";
@ -505,18 +548,21 @@ public class Idea extends DomainObject {
return "Unmatched";
}
},
MATCHED {
@Override
public String toString() {
return "Matched, no project";
}
},
COMPLETED {
@Override
public String toString() {
return "Matched, has project";
}
},
INACTIVE {
@Override
public String toString() {

View File

@ -1,8 +1,18 @@
package se.su.dsv.scipro.match;
import jakarta.persistence.Basic;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import se.su.dsv.scipro.system.DomainObject;
import jakarta.persistence.*;
import java.util.Objects;
@Entity
@ -11,56 +21,69 @@ public class IdeaExport extends DomainObject {
public enum Result { FAIL, SUCCESS }
// ----------------------------------------------------------------------------------
// basic and embedded JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
private Result result;
@Basic
private String reason;
@Enumerated(EnumType.STRING)
private Result result;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (idea_export) referencing other tables
// ----------------------------------------------------------------------------------
@ManyToOne(optional = false)
@JoinColumn(name = "idea_id", referencedColumnName = "id")
private Idea idea;
public boolean wasSuccessful() {
return result == Result.SUCCESS;
}
// ----------------------------------------------------------------------------------
// getters and setters
// ----------------------------------------------------------------------------------
@Override
public Long getId() {
return this.id;
}
public Result getResult() {
return this.result;
}
public String getReason() {
return this.reason;
}
public Idea getIdea() {
return this.idea;
}
public void setId(Long id) {
this.id = id;
}
public void setResult(Result result) {
this.result = result;
public String getReason() {
return this.reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public Result getResult() {
return this.result;
}
public void setResult(Result result) {
this.result = result;
}
public Idea getIdea() {
return this.idea;
}
public void setIdea(Idea idea) {
this.idea = idea;
}
// ----------------------------------------------------------------------------------
// other methods
// ----------------------------------------------------------------------------------
public boolean wasSuccessful() {
return result == Result.SUCCESS;
}
@Override
public boolean equals(final Object o) {
if (o == this) return true;

View File

@ -1,83 +1,115 @@
package se.su.dsv.scipro.match;
import jakarta.persistence.AssociationOverride;
import jakarta.persistence.AssociationOverrides;
import jakarta.persistence.Basic;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import se.su.dsv.scipro.system.Program;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
@Entity
@Table(name = "idea_student")
@AssociationOverrides({
@AssociationOverride(name = "idea",
joinColumns = @JoinColumn(name = "idea_id")) })
public class IdeaParticipation implements Serializable {
protected IdeaParticipation() {
}
public IdeaParticipation(User student, Idea idea) {
this.user = student;
this.idea = idea;
}
// ----------------------------------------------------------------------------------
// basic and embedded JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private User user;
@ManyToOne
private Idea idea;
@Basic
private Date dateCreated = new Date();
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (idea_student) referencing other tables.
// ----------------------------------------------------------------------------------
@ManyToOne
@JoinColumn(name = "idea_id", referencedColumnName = "id")
private Idea idea;
@ManyToOne(optional = true)
@JoinColumn(name = "program_id", referencedColumnName = "id")
private Program program;
@ManyToOne
@JoinColumn(name = "user_id", referencedColumnName = "id")
private User user;
// ----------------------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------------------
// JPA/Hibernate works by create a child class of your entity class with all database
// tricks in it, it therefore requires no-arg constructor to be able to instantiate
// a new instance.
// By creating a protected constructor, JPA/Hibernate still works as expected, but it
// declares the intention that parameters need to be provided when new instances are
// created.
protected IdeaParticipation() { }
public IdeaParticipation(User student, Idea idea) {
this.user = student;
this.idea = idea;
}
// ----------------------------------------------------------------------------
// getters and setters
// ----------------------------------------------------------------------------
public Long getId() {
return this.id;
}
public User getUser() {
return this.user;
}
public Idea getIdea() {
return this.idea;
}
public Date getDateCreated() {
return this.dateCreated;
}
public Program getProgram() {
return this.program;
}
public void setId(Long id) {
this.id = id;
}
public void setUser(User user) {
this.user = user;
}
public void setIdea(Idea idea) {
this.idea = idea;
public Date getDateCreated() {
return this.dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public Idea getIdea() {
return this.idea;
}
public void setIdea(Idea idea) {
this.idea = idea;
}
public Program getProgram() {
return this.program;
}
public void setProgram(Program program) {
this.program = program;
}
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
// ----------------------------------------------------------------------------
// methods
// ----------------------------------------------------------------------------
@Override
public String toString() {
return "IdeaParticipation(id=" + this.getId() + ", user=" + this.getUser() + ", idea=" + this.getIdea() + ", dateCreated=" + this.getDateCreated() + ", program=" + this.getProgram() + ")";

View File

@ -1,56 +1,85 @@
package se.su.dsv.scipro.match;
import com.querydsl.core.annotations.QueryInit;
import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.*;
import java.util.Objects;
@Entity
@Cacheable(true)
@Table(name = "idea_match")
@Cacheable(true)
public class Match extends DomainObject {
// ----------------------------------------------------------------------------------
// basic JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(optional = false)
private Idea idea;
@ManyToOne
@QueryInit({"unit"})
private User supervisor;
@Basic
@Enumerated(EnumType.STRING)
private Idea.Status status;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (idea_match) referencing other tables.
// ----------------------------------------------------------------------------------
@ManyToOne(optional = true)
@JoinColumn(name = "changed_by_user_id", referencedColumnName = "id")
private User changedBy;
public User getSupervisor() {
return supervisor;
}
@ManyToOne(optional = false)
@JoinColumn(name = "idea_id", referencedColumnName = "id")
private Idea idea;
@ManyToOne
@JoinColumn(name = "supervisor_user_id", referencedColumnName = "id")
@QueryInit({"unit"})
private User supervisor;
// ----------------------------------------------------------------------------------
// getters and setters
// ----------------------------------------------------------------------------------
@Override
public Long getId() {
return this.id;
}
public Idea getIdea() {
return this.idea;
public void setId(Long id) {
this.id = id;
}
public Idea.Status getStatus() {
return this.status;
}
public void setStatus(Idea.Status status) {
this.status = status;
}
public User getChangedBy() {
return this.changedBy;
}
public void setId(Long id) {
this.id = id;
public void setChangedBy(User changedBy) {
this.changedBy = changedBy;
}
public Idea getIdea() {
return this.idea;
}
public void setIdea(Idea idea) {
@ -61,14 +90,13 @@ public class Match extends DomainObject {
this.supervisor = supervisor;
}
public void setStatus(Idea.Status status) {
this.status = status;
}
public void setChangedBy(User changedBy) {
this.changedBy = changedBy;
public User getSupervisor() {
return supervisor;
}
// ----------------------------------------------------------------------------------
// other methods
// ----------------------------------------------------------------------------------
@Override
public boolean equals(final Object o) {
if (o == this) return true;
@ -93,6 +121,7 @@ public class Match extends DomainObject {
@Override
public String toString() {
return "Match(id=" + this.getId() + ", supervisor=" + this.getSupervisor() + ", status=" + this.getStatus() + ", changedBy=" + this.getChangedBy() + ")";
return "Match(id=" + this.getId() + ", supervisor=" + this.getSupervisor() + ", status=" + this.getStatus() +
", changedBy=" + this.getChangedBy() + ")";
}
}

View File

@ -1,70 +1,98 @@
package se.su.dsv.scipro.match;
import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.*;
import java.util.Objects;
@Entity
@Table(name = "preliminary_match")
public class PreliminaryMatch extends DomainObject {
// ----------------------------------------------------------------------------------
// basic JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Basic
@Column(name = "comment")
private String comment;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (idea_first_meeting) referencing other
// tables.
// ----------------------------------------------------------------------------------
@ManyToOne
@JoinColumn(name = "idea_id", referencedColumnName = "id")
private Idea idea;
@ManyToOne
@JoinColumn(name = "supervisor_user_id", referencedColumnName = "id")
private User supervisor;
private String comment;
// JPA
public PreliminaryMatch() {
}
// ----------------------------------------------------------------------------------
// constructors
// ----------------------------------------------------------------------------------
public PreliminaryMatch() { }
public PreliminaryMatch(final Idea idea) {
this.idea = idea;
}
// ----------------------------------------------------------------------------------
// getters and setters
// ----------------------------------------------------------------------------------
@Override
public Long getId() {
return this.id;
}
public Idea getIdea() {
return this.idea;
}
public User getSupervisor() {
return this.supervisor;
}
public String getComment() {
return this.comment;
}
public void setId(Long id) {
this.id = id;
}
public void setIdea(Idea idea) {
this.idea = idea;
}
public void setSupervisor(User supervisor) {
this.supervisor = supervisor;
public String getComment() {
return this.comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Idea getIdea() {
return this.idea;
}
public void setIdea(Idea idea) {
this.idea = idea;
}
public User getSupervisor() {
return this.supervisor;
}
public void setSupervisor(User supervisor) {
this.supervisor = supervisor;
}
// ----------------------------------------------------------------------------------
// other methods
// ----------------------------------------------------------------------------------
@Override
public String toString() {
return "PreliminaryMatch(id=" + this.getId() + ", idea=" + this.getIdea() + ", supervisor=" + this.getSupervisor() + ", comment=" + this.getComment() + ")";
return "PreliminaryMatch(id=" + this.getId() + ", idea=" + this.getIdea() + ", supervisor=" +
this.getSupervisor() + ", comment=" + this.getComment() + ")";
}
@Override

View File

@ -26,7 +26,13 @@ import jakarta.persistence.Table;
import se.su.dsv.scipro.data.dataobjects.Member;
import se.su.dsv.scipro.reusable.SciProUtilities;
import se.su.dsv.scipro.system.*;
import se.su.dsv.scipro.system.DegreeType;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.Language;
import se.su.dsv.scipro.system.ProjectModule;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.ResearchArea;
import se.su.dsv.scipro.system.User;
import java.time.LocalDate;
import java.util.ArrayList;

View File

@ -1599,11 +1599,160 @@ alter table `keyword_research_area`
foreign key (research_area_id) references research_area (id)
on delete cascade on update cascade;
/*
* Step 10: idea related tables
*/
-- table: idea
alter table `idea` drop foreign key `FK6E051897B9431B73`;
alter table `idea` drop foreign key `FK6E051897C1813915`;
alter table `idea` drop foreign key `FK6E051897E44F4DBE`;
alter table `idea` drop key `FK6E051897C1813915`;
alter table `idea` drop key `FK6E051897B9431B73`;
alter table `idea` drop key `FK6E051897E44F4DBE`;
alter table `idea` change `published` `published` bit(1) not null default b'1' after `type`;
alter table `idea` change `cachedStatus` `cached_status` varchar(255) default null after `published`;
alter table `idea` change `inactive` `inactive` tinyint(1) not null default 0 after `cached_status`;
alter table `idea` change `practicalHow` `practical_how` longtext default null after `inactive`;
alter table `idea` change `theoryHow` `theory_how` longtext default null after `practical_how`;
alter table `idea` change `literature` `literature` longtext default null after `why`;
alter table `idea` change `background` `background` longtext default null after `literature`;
alter table `idea` change `problem` `problem` longtext default null after `background`;
alter table `idea` change `method` `method` longtext default null after `problem`;
alter table `idea` change `interests` `interests` longtext default null after `method`;
alter table `idea` rename column `creator_id` to `creator_user_id`;
alter table `idea` rename column `match_id` to `latest_match_id`;
alter table `idea`
add constraint fk_idea_creator_user_id
foreign key (creator_user_id) references user (id)
on delete cascade on update cascade;
alter table `idea`
add constraint fk_idea_latest_match_id
foreign key (latest_match_id) references idea_match (id)
on delete cascade on update cascade;
alter table `idea`
add constraint fk_idea_project_id
foreign key (project_id) references project (id)
on delete cascade on update cascade;
-- table: idea_language
alter table `idea_language` drop foreign key `FK_idea_language_idea`;
alter table `idea_language` drop key `FK_idea_language_idea`;
alter table `idea_language`
add constraint fk_idea_language_idea_id
foreign key (idea_id) references idea (id)
on delete cascade on update cascade;
-- table: idea_export
alter table `idea_export` drop foreign key `FK68FA705CFCDADF61`;
alter table `idea_export` drop key `FK68FA705CFCDADF61`;
alter table `idea_export`
add constraint fk_idea_export_idea_id
foreign key (idea_id) references idea (id)
on delete cascade on update cascade;
-- table: idea_first_meeting
alter table `idea_first_meeting` drop foreign key `FK9393AA04FCDADF61`;
alter table `idea_first_meeting` drop key `FK9393AA04FCDADF61`;
alter table `idea_first_meeting` drop key `UK_k4m4tupnikallbq3cq3llvlmk`;
alter table `idea_first_meeting` drop key `idea_id`;
alter table `idea_first_meeting` rename column `firstMeetingDate` to `first_meeting_date`;
alter table `idea_first_meeting` change `room` `room` longtext not null after `first_meeting_date`;
alter table `idea_first_meeting`
add constraint fk_idea_first_meeting_idea_id
foreign key (idea_id) references idea (id)
on delete cascade on update cascade;
alter table `idea_first_meeting`
add constraint uk_idea_first_meeting_idea_id unique(idea_id);
-- table: idea_match
alter table `idea_match` drop foreign key `FK87EA481DFCDADF61`;
alter table `idea_match` drop foreign key `FK87EA481DA89FFB7F`;
alter table `idea_match` drop foreign key `idea_match_supervisor_id`;
alter table `idea_match` drop key `FK87EA481DFCDADF61`;
alter table `idea_match` drop key `FK87EA481DA89FFB7F`;
alter table `idea_match` drop key `idea_match_supervisor_id`;
alter table `idea_match` rename column `changedBy_id` to `changed_by_user_id`;
alter table `idea_match` rename column `supervisor_id` to `supervisor_user_id`;
alter table `idea_match`
add constraint fk_idea_match_idea_id
foreign key (idea_id) references idea (id)
on delete cascade on update cascade;
alter table `idea_match`
add constraint fk_idea_match_changed_by_user_id
foreign key (changed_by_user_id) references user (id)
on delete cascade on update cascade;
alter table `idea_match`
add constraint fk_idea_match_supervisor_user_id
foreign key (supervisor_user_id) references user (id)
on delete cascade on update cascade;
-- table: preliminary_match
alter table `preliminary_match` drop foreign key `FK_preliminary_match_supervisor`;
alter table `preliminary_match` drop foreign key `FK_preliminary_match_idea`;
alter table `preliminary_match` drop key `FK_preliminary_match_supervisor`;
alter table `preliminary_match` drop key `FK_preliminary_match_idea`;
alter table `preliminary_match` change `comment` `comment` mediumtext default null after `version`;
alter table `preliminary_match` rename column `supervisor_id` to `supervisor_user_id`;
alter table `preliminary_match`
add constraint fk_preliminary_match_idea_id
foreign key (idea_id) references idea (id)
on delete cascade on update cascade;
alter table `preliminary_match`
add constraint fk_preliminary_match_supervisor_user_id
foreign key (supervisor_user_id) references user (id)
on delete cascade on update cascade;
-- table: idea_student
alter table `idea_student` drop foreign key `idea_student_user_id`;
alter table `idea_student` drop foreign key `FK9458BA93FCDADF61`;
alter table `idea_student` drop key `idea_student_user_id`;
alter table `idea_student` drop key `FK9458BA93FCDADF61`;
alter table `idea_student` drop key `FK_c5py593l4g261jdkuvwdmcmgj`;
alter table `idea_student` rename column `dateCreated` to `date_created`;
alter table `idea_student` change `id` `id` bigint(20) not null auto_increment first;
alter table `idea_student`
add constraint fk_idea_student_idea_id
foreign key (idea_id) references idea (id)
on delete cascade on update cascade;
alter table `idea_student`
add constraint fk_idea_student_user_id
foreign key (user_id) references user (id)
on delete cascade on update cascade;