task/3382: Harmonisera tabellnamn #6
@ -18,27 +18,38 @@ import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "grading_history_submissions")
|
||||
@Table(name = "grading_history_submission")
|
||||
public class SubmissionEvent {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "project_id")
|
||||
private Project project;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "author_id")
|
||||
private User author;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "`when`")
|
||||
private Instant when;
|
||||
|
||||
@Basic
|
||||
@Column(name = "corrections")
|
||||
private String corrections;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (grading_history_submission) referencing
|
||||
// other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
private Project project;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "author_user_id", referencedColumnName = "id")
|
||||
private User author;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -47,22 +58,6 @@ public class SubmissionEvent {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public User getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(User user) {
|
||||
this.author = user;
|
||||
}
|
||||
|
||||
public Instant getWhen() {
|
||||
return when;
|
||||
}
|
||||
@ -79,6 +74,25 @@ public class SubmissionEvent {
|
||||
this.corrections = corrections;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public User getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(User user) {
|
||||
this.author = user;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@ -97,11 +111,8 @@ public class SubmissionEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RejectionEvent{" +
|
||||
"id=" + id +
|
||||
", project=" + project +
|
||||
", author=" + author +
|
||||
", when=" + when +
|
||||
return "RejectionEvent{" + "id=" + id + ", project=" + project +
|
||||
", author=" + author + ", when=" + when +
|
||||
", corrections='" + corrections + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
@ -1,26 +1,34 @@
|
||||
package se.su.dsv.scipro.project;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
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.system.User;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "project_user")
|
||||
public class Author {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Embedded JPA-mapping
|
||||
// ----------------------------------------------------------------------------------
|
||||
@EmbeddedId
|
||||
private AuthorPK authorPK;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "project_id", nullable = false)
|
||||
@MapsId("projectId")
|
||||
private Project project;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
@MapsId("userId")
|
||||
private User user;
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Basic(optional = true)
|
||||
@Column(name = "reflection")
|
||||
private String reflection;
|
||||
|
||||
/**
|
||||
* If this author wants to be notified when a final seminar created
|
||||
@ -36,15 +44,29 @@ public class Author {
|
||||
@Column(name = "subscribed_to_final_seminar_notifications", nullable = false, columnDefinition = "BOOLEAN DEFAULT FALSE")
|
||||
private boolean subscribedToFinalSeminarNotifications;
|
||||
|
||||
@Basic(optional = true)
|
||||
private String reflection;
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (project_user) referencing other
|
||||
// tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "project_id", nullable = false)
|
||||
@MapsId("projectId")
|
||||
private Project project;
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
@MapsId("userId")
|
||||
private User user;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
public String getReflection() {
|
||||
return reflection;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
public void setReflection(String reflection) {
|
||||
this.reflection = reflection;
|
||||
}
|
||||
|
||||
public boolean isSubscribedToFinalSeminarNotifications() {
|
||||
@ -55,14 +77,17 @@ public class Author {
|
||||
this.subscribedToFinalSeminarNotifications = subscribedToFinalSeminarNotifications;
|
||||
}
|
||||
|
||||
public String getReflection() {
|
||||
return reflection;
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setReflection(String reflection) {
|
||||
this.reflection = reflection;
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Nested class
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Embeddable
|
||||
public static class AuthorPK implements Serializable {
|
||||
private Long projectId;
|
||||
|
@ -115,7 +115,7 @@ public class Project extends DomainObject {
|
||||
private Integer identifier;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Embedded JPA-mappings
|
||||
// Embedded JPA-mapping
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Embedded
|
||||
@AttributeOverride(name = "name", column = @Column(name = "external_organization"))
|
||||
@ -185,7 +185,6 @@ public class Project extends DomainObject {
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
|
@ -1,84 +1,103 @@
|
||||
package se.su.dsv.scipro.thesislink;
|
||||
|
||||
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.project.Project;
|
||||
import se.su.dsv.scipro.system.DomainObject;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "externallink")
|
||||
@Table(name = "external_link")
|
||||
public class ExternalLink extends DomainObject {
|
||||
|
||||
public static final int MAX_CHARS = 255;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private Project project;
|
||||
|
||||
@Column(nullable = false, length = MAX_CHARS)
|
||||
private String url = "";
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private User user;
|
||||
|
||||
@Column(nullable = true, length = MAX_CHARS)
|
||||
private String description = "";
|
||||
|
||||
public static IProject builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Basic JPA-mappings
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Basic
|
||||
@Column(name = "url", nullable = false, length = MAX_CHARS)
|
||||
private String url = "";
|
||||
|
||||
@Column(name = "description", nullable = true, length = MAX_CHARS)
|
||||
private String description = "";
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// JPA-mappings of foreign keys in this table (external_link) referencing
|
||||
// other tables.
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id")
|
||||
private Project project;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "user_id", referencedColumnName = "id")
|
||||
private User user;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Properties (Getters and Setters)
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExternalLink(id=" + this.getId() + ", project=" + this.getProject() + ", url=" + this.getUrl() + ", user=" + this.getUser() + ", description=" + this.getDescription() + ")";
|
||||
public Project getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Methods Common To All Objects
|
||||
// ----------------------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) return true;
|
||||
@ -92,15 +111,28 @@ public class ExternalLink extends DomainObject {
|
||||
&& Objects.equals(this.getDescription(), other.getDescription());
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ExternalLink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.getId(), this.getProject(), this.getUrl(), this.getUser(), this.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExternalLink(id=" + this.getId() + ", project=" + this.getProject() +
|
||||
", url=" + this.getUrl() + ", user=" + this.getUser() + ", description=" +
|
||||
this.getDescription() + ")";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Other method
|
||||
// ----------------------------------------------------------------------------------
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof ExternalLink;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Nested types
|
||||
// ----------------------------------------------------------------------------------
|
||||
private static class Builder implements IProject, IURL, IUser, IBuild {
|
||||
private ExternalLink instance = new ExternalLink();
|
||||
|
||||
|
@ -2484,18 +2484,135 @@ alter table `project_user_note`
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- todo: table: project_cosupervisor
|
||||
-- table: project_cosupervisor
|
||||
|
||||
alter table `project_cosupervisor` drop foreign key `FK_fj57t069dymdrnnhdxcnfvvnn`;
|
||||
alter table `project_cosupervisor` drop foreign key `FK_18x2poxkt8s2bw9kpr7vbmd5j`;
|
||||
|
||||
-- todo: table: project_reviewer
|
||||
alter table `project_cosupervisor` drop key `FK_fj57t069dymdrnnhdxcnfvvnn`;
|
||||
alter table `project_cosupervisor` drop key `FK_18x2poxkt8s2bw9kpr7vbmd5j`;
|
||||
|
||||
-- todo: table: project_user
|
||||
alter table `project_cosupervisor` change `user_id` `user_id` bigint(20) not null after `project_id`;
|
||||
|
||||
-- todo: table: grading_history_submissions
|
||||
alter table `project_cosupervisor`
|
||||
add constraint fk_project_cosupervisor_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- todo: table: externallink
|
||||
alter table `project_cosupervisor`
|
||||
add constraint fk_project_cosupervisor_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: project_reviewer
|
||||
|
||||
alter table `project_reviewer` drop foreign key `FK_g7yryw3e0dtmuuvgw5qjhphjm`;
|
||||
alter table `project_reviewer` drop foreign key `FK_6aik0jd18kv3383fbt09xd0pi`;
|
||||
|
||||
alter table `project_reviewer` drop key `FK_6aik0jd18kv3383fbt09xd0pi`;
|
||||
alter table `project_reviewer` drop key `FK_g7yryw3e0dtmuuvgw5qjhphjm`;
|
||||
|
||||
alter table `project_reviewer`
|
||||
add constraint fk_project_reviewer_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `project_reviewer`
|
||||
add constraint fk_project_reviewer_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: project_user
|
||||
|
||||
alter table `project_user` drop foreign key `project_user_user_id`;
|
||||
alter table `project_user` drop foreign key `project_user_project_id`;
|
||||
|
||||
alter table `project_user` drop key `project_user_project_id`;
|
||||
|
||||
alter table `project_user` change `user_id` `user_id` bigint(20) not null after `project_id`;
|
||||
alter table `project_user` change `reflection` `reflection` text default null after `user_id`;
|
||||
|
||||
alter table `project_user`
|
||||
add constraint fk_project_user_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `project_user`
|
||||
add constraint fk_project_user_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: grading_history_submissions
|
||||
|
||||
alter table `grading_history_submissions` drop foreign key `FK_grading_history_submissions_project`;
|
||||
alter table `grading_history_submissions` drop foreign key `FK_grading_history_submissions_author`;
|
||||
|
||||
alter table `grading_history_submissions` drop key `FK_grading_history_submissions_project`;
|
||||
alter table `grading_history_submissions` drop key `FK_grading_history_submissions_author`;
|
||||
|
||||
rename table `grading_history_submissions` to `grading_history_submission`;
|
||||
|
||||
alter table `grading_history_submission` change `when` `when` timestamp not null default '0000-00-00 00:00:00' after `id`;
|
||||
alter table `grading_history_submission` change `corrections` `corrections` text default null after `when`;
|
||||
alter table `grading_history_submission` change `author_id` `author_user_id` bigint(20) not null after `corrections`;
|
||||
|
||||
alter table `grading_history_submission`
|
||||
add constraint fk_grading_history_submission_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `grading_history_submission`
|
||||
add constraint fk_grading_history_submission_author_user_id
|
||||
foreign key (author_user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: externallink
|
||||
|
||||
alter table `externallink` drop foreign key `FK_PROJECT`;
|
||||
alter table `externallink` drop foreign key `FK_USER`;
|
||||
|
||||
alter table `externallink` drop key `FK_PROJECT`;
|
||||
alter table `externallink` drop key `FK_USER`;
|
||||
|
||||
rename table `externallink` to `external_link`;
|
||||
|
||||
alter table `external_link` change `description` `description` varchar(255) default null after `url`;
|
||||
|
||||
alter table `external_link`
|
||||
add constraint fk_external_link_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `external_link`
|
||||
add constraint fk_external_link_user_id
|
||||
foreign key (user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- table: grade
|
||||
|
||||
alter table `grade` drop foreign key `FK_grade_user_reportedBy`;
|
||||
alter table `grade` drop foreign key `FK_grade_project`;
|
||||
|
||||
alter table `grade` drop key `FK_grade_user_reportedBy`;
|
||||
alter table `grade` drop key `project_id`;
|
||||
|
||||
alter table `grade` change `value` `value` varchar(255) not null after `id`;
|
||||
alter table `grade` change `reportedOn` `reported_when` date not null after `value`;
|
||||
alter table `grade` change `project_id` `project_id` bigint(20) not null after `reported_when`;
|
||||
alter table `grade` change `reportedBy` `reported_by_user_id` bigint(20) not null after `project_id`;
|
||||
|
||||
alter table `grade` add constraint uk_grade_project_id unique(project_id);
|
||||
|
||||
alter table `grade`
|
||||
add constraint fk_grade_project_id
|
||||
foreign key (project_id) references project (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
alter table `grade`
|
||||
add constraint fk_grade_reported_by_user_id
|
||||
foreign key (reported_by_user_id) references user (id)
|
||||
on delete cascade on update cascade;
|
||||
|
||||
-- todo: table: grade
|
||||
|
||||
|
||||
|
||||
@ -2527,7 +2644,7 @@ order by table_name;
|
||||
select table_name, column_name, constraint_name, referenced_table_name, referenced_column_name
|
||||
from information_schema.key_column_usage
|
||||
where table_schema = 'tozh4728' and
|
||||
table_name = 'criterion' and
|
||||
table_name = 'grade' and
|
||||
constraint_name != 'PRIMARY';
|
||||
|
||||
-- show foreign keys for all tables
|
||||
@ -2537,9 +2654,6 @@ order by table_name;
|
||||
constraint_name != 'PRIMARY'
|
||||
order by table_name collate utf8_nopad_bin, constraint_name collate utf8_nopad_bin;
|
||||
|
||||
|
||||
> Show collation;
|
||||
|
||||
|
||||
>>> Show collation;
|
||||
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user