task/3382: Harmonisera tabellnamn #6
@ -1,14 +1,21 @@
|
||||
package se.su.dsv.scipro.forum.dataobjects;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "forum_post_read")
|
||||
@Table(name = "forum_post_read_state")
|
||||
public class ForumPostReadState implements Serializable {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic and embedded JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@EmbeddedId
|
||||
private ForumPostReadStateId id;
|
||||
|
||||
@ -16,6 +23,9 @@ public class ForumPostReadState implements Serializable {
|
||||
@Column(name = "`read`", nullable = false)
|
||||
private boolean read = false;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------------------
|
||||
public ForumPostReadState() {
|
||||
}
|
||||
|
||||
@ -23,6 +33,9 @@ public class ForumPostReadState implements Serializable {
|
||||
id = new ForumPostReadStateId(user, post);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public ForumPostReadStateId getId() {
|
||||
return id;
|
||||
}
|
||||
@ -39,4 +52,3 @@ public class ForumPostReadState implements Serializable {
|
||||
this.read = read;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,11 @@ import java.util.Objects;
|
||||
@Embeddable
|
||||
public class ForumPostReadStateId implements Serializable {
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user", nullable = false)
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "post", nullable = false)
|
||||
@JoinColumn(name = "forum_post_id", nullable = false)
|
||||
private ForumPost post;
|
||||
|
||||
public ForumPostReadStateId() {
|
||||
|
@ -1,49 +1,70 @@
|
||||
package se.su.dsv.scipro.forum.dataobjects;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
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.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import se.su.dsv.scipro.group.Group;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "group_thread")
|
||||
@Table(name = "project_group_thread")
|
||||
public class GroupThread implements Serializable {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (project_group_thread) referencing other
|
||||
// tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "group_id", nullable = false)
|
||||
@JoinColumn(name = "project_group_id", referencedColumnName = "id", nullable = false)
|
||||
private Group group;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, optional = false)
|
||||
@JoinColumn(name = "thread_id")
|
||||
@JoinColumn(name = "thread_id", referencedColumnName = "id")
|
||||
private ForumThread forumThread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Long getId() { return id; }
|
||||
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public ForumThread getForumThread() {
|
||||
return forumThread;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(Group group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public ForumThread getForumThread() {
|
||||
return forumThread;
|
||||
}
|
||||
|
||||
public void setForumThread(ForumThread forumThread) {
|
||||
this.forumThread = forumThread;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -55,10 +76,6 @@ public class GroupThread implements Serializable {
|
||||
&& Objects.equals(this.getForumThread(), other.getForumThread());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof GroupThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getGroup(), this.getForumThread());
|
||||
@ -66,6 +83,14 @@ public class GroupThread implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupThread(id=" + this.getId() + ", group=" + this.getGroup() + ", forumThread=" + this.getForumThread() + ")";
|
||||
return "GroupThread(id=" + this.getId() + ", group=" + this.getGroup() + ", forumThread=" +
|
||||
this.getForumThread() + ")";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof GroupThread;
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,70 @@
|
||||
package se.su.dsv.scipro.forum.dataobjects;
|
||||
|
||||
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.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import se.su.dsv.scipro.project.Project;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "project_thread")
|
||||
public class ProjectThread implements Serializable {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "thread_id")
|
||||
private ForumThread forumThread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (project_thread) referencing other
|
||||
// tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "project_id")
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
private Project project;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "thread_id", referencedColumnName = "id")
|
||||
private ForumThread forumThread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public ForumThread getForumThread() {
|
||||
return forumThread;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setForumThread(ForumThread forumThread) {
|
||||
this.forumThread = forumThread;
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public ForumThread getForumThread() {
|
||||
return forumThread;
|
||||
}
|
||||
|
||||
public void setForumThread(ForumThread forumThread) {
|
||||
this.forumThread = forumThread;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -56,10 +76,6 @@ public class ProjectThread implements Serializable {
|
||||
&& Objects.equals(this.getProject(), other.getProject());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ProjectThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getForumThread(), this.getProject());
|
||||
@ -67,6 +83,14 @@ public class ProjectThread implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectThread(id=" + this.getId() + ", forumThread=" + this.getForumThread() + ", project=" + this.getProject() + ")";
|
||||
return "ProjectThread(id=" + this.getId() + ", forumThread=" + this.getForumThread() +
|
||||
", project=" + this.getProject() + ")";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ProjectThread;
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,69 @@
|
||||
package se.su.dsv.scipro.forum.dataobjects;
|
||||
|
||||
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.project.Project;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "reviewer_thread")
|
||||
public class ReviewerThread {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mapping
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "thread_id")
|
||||
private ForumThread forumThread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (mail_event) referencing other
|
||||
// tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToOne
|
||||
@JoinColumn(name = "project_id", unique = true)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id", unique = true)
|
||||
private Project project;
|
||||
|
||||
@OneToOne(optional = false)
|
||||
@JoinColumn(name = "thread_id", referencedColumnName = "id")
|
||||
private ForumThread forumThread;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public ForumThread getForumThread() {
|
||||
return this.forumThread;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setForumThread(ForumThread forumThread) {
|
||||
this.forumThread = forumThread;
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public ForumThread getForumThread() {
|
||||
return this.forumThread;
|
||||
}
|
||||
|
||||
public void setForumThread(ForumThread forumThread) {
|
||||
this.forumThread = forumThread;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -56,10 +75,6 @@ public class ReviewerThread {
|
||||
&& Objects.equals(this.getProject(), other.getProject());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ReviewerThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getForumThread(), this.getProject());
|
||||
@ -67,6 +82,14 @@ public class ReviewerThread {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReviewerThread(id=" + this.getId() + ", forumThread=" + this.getForumThread() + ", project=" + this.getProject() + ")";
|
||||
return "ReviewerThread(id=" + this.getId() + ", forumThread=" + this.getForumThread() +
|
||||
", project=" + this.getProject() + ")";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other methods
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ReviewerThread;
|
||||
}
|
||||
}
|
||||
|
@ -2973,6 +2973,102 @@ alter table `forum_post_file_reference`
|
||||
foreign key (file_reference_id) references file_reference (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
/*
|
||||
* Step 23: forum_post_read, project_thread, reviewer_thread and group_thread
|
||||
*/
|
||||
|
||||
-- table: forum_post_read
|
||||
|
||||
alter table `forum_post_read` drop foreign key `FK8A5DFC60DD74550D`;
|
||||
alter table `forum_post_read` drop foreign key `FK8A5DFC60924F477B`;
|
||||
|
||||
alter table `forum_post_read` drop key `FK8A5DFC60DD74550D`;
|
||||
alter table `forum_post_read` drop key `FK8A5DFC60924F477B`;
|
||||
|
||||
alter table `forum_post_read` drop primary key;
|
||||
|
||||
rename table `forum_post_read` to `forum_post_read_state`;
|
||||
|
||||
alter table `forum_post_read_state` change `read` `read` tinyint(1) not null after `post`;
|
||||
alter table `forum_post_read_state` change `user` `user_id` bigint(20) not null after `post`;
|
||||
alter table `forum_post_read_state` change `post` `forum_post_id` bigint(20) not null;
|
||||
|
||||
alter table `forum_post_read_state` add primary key (forum_post_id, user_id);
|
||||
|
||||
alter table `forum_post_read_state`
|
||||
add constraint fk_forum_post_read_state_forum_post_id
|
||||
foreign key (forum_post_id) references forum_post (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `forum_post_read_state`
|
||||
add constraint fk_forum_post_read_state_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: project_thread
|
||||
|
||||
alter table `project_thread` drop foreign key `FK_project_thread_thread`;
|
||||
alter table `project_thread` drop foreign key `FK_project_thread_project`;
|
||||
|
||||
alter table `project_thread` drop key `FK_project_thread_thread`;
|
||||
alter table `project_thread` drop key `FK_project_thread_project`;
|
||||
|
||||
alter table `project_thread` change `project_id` `project_id` bigint(20) not null after `id`;
|
||||
|
||||
alter table `project_thread`
|
||||
add constraint fk_project_thread_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `project_thread`
|
||||
add constraint fk_project_thread_thread_id
|
||||
foreign key (thread_id) references thread (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: reviewer_thread
|
||||
|
||||
alter table `reviewer_thread` drop foreign key `FK_reviewer_thread_thread`;
|
||||
alter table `reviewer_thread` drop foreign key `FK_reviewer_thread_group`;
|
||||
|
||||
alter table `reviewer_thread` drop key `FK_reviewer_thread_thread`;
|
||||
alter table `reviewer_thread` drop key `project_id`;
|
||||
|
||||
alter table `reviewer_thread` change `thread_id` `thread_id` bigint(20) not null after `project_id`;
|
||||
|
||||
alter table `reviewer_thread` add constraint uk_reviewer_thread_project_id unique(project_id, thread_id);
|
||||
|
||||
alter table `reviewer_thread`
|
||||
add constraint fk_reviewer_thread_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `reviewer_thread`
|
||||
add constraint fk_reviewer_thread_thread_id
|
||||
foreign key (thread_id) references thread (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: group_thread
|
||||
|
||||
alter table `group_thread` drop foreign key `FK_project_group_thread_thread`;
|
||||
alter table `group_thread` drop foreign key `FK_project_group_thread_group`;
|
||||
|
||||
alter table `group_thread` drop key `FK_project_group_thread_thread`;
|
||||
alter table `group_thread` drop key `project_group`;
|
||||
|
||||
rename table `group_thread` to `project_group_thread`;
|
||||
|
||||
alter table `project_group_thread` change `group_id` `project_group_id` bigint(20) not null after `id`;
|
||||
|
||||
alter table `project_group_thread`
|
||||
add constraint fk_project_group_thread_project_group_id
|
||||
foreign key (project_group_id) references project_group (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `project_group_thread`
|
||||
add constraint fk_project_group_thread_thread_id
|
||||
foreign key (thread_id) references thread (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
|
||||
/* Useful SQL
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user