task/3382: Harmonisera tabellnamn #6

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

View File

@ -11,46 +11,61 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.util.*;
import java.util.Objects;
@Entity
@Table(name = "plagiarism_request")
class PlagiarismRequest {
// ----------------------------------------------------------------------------------
// Basic JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (plagiarism_request) referencing other
// tables.
// ----------------------------------------------------------------------------------
@OneToOne(optional = false)
@JoinColumn(name = "document_reference_id")
@JoinColumn(name = "document_file_reference_id", referencedColumnName = "id")
private FileReference document;
@ManyToOne
@JoinColumn(name = "receiver_user_id", referencedColumnName = "id")
private User receiver;
// ----------------------------------------------------------------------------------
// Properties (Getters and Setters)
// ----------------------------------------------------------------------------------
public Long getId() {
return this.id;
}
public FileReference getDocument() {
return this.document;
}
public User getReceiver() {
return this.receiver;
}
public void setId(Long id) {
this.id = id;
}
public FileReference getDocument() {
return this.document;
}
public void setDocument(FileReference fileDescription) {
this.document = fileDescription;
}
public User getReceiver() {
return this.receiver;
}
public void setReceiver(User receiver) {
this.receiver = receiver;
}
// ----------------------------------------------------------------------------------
// Methods Common To All Objects
// ----------------------------------------------------------------------------------
@Override
public boolean equals(final Object o) {
if (o == this) return true;
@ -62,10 +77,6 @@ class PlagiarismRequest {
&& Objects.equals(this.getReceiver(), other.getReceiver());
}
protected boolean canEqual(final Object other) {
return other instanceof PlagiarismRequest;
}
@Override
public int hashCode() {
return Objects.hash(this.getId(), this.getDocument(), this.getReceiver());
@ -73,6 +84,14 @@ class PlagiarismRequest {
@Override
public String toString() {
return "PlagiarismRequest(id=" + this.getId() + ", fileDescription=" + this.getDocument() + ", receiver=" + this.getReceiver() + ")";
return "PlagiarismRequest(id=" + this.getId() + ", fileDescription=" + this.getDocument() +
", receiver=" + this.getReceiver() + ")";
}
// ----------------------------------------------------------------------------------
// Other method
// ----------------------------------------------------------------------------------
protected boolean canEqual(final Object other) {
return other instanceof PlagiarismRequest;
}
}

View File

@ -17,139 +17,159 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.time.Instant;
import java.util.*;
import java.util.Objects;
@Entity
@Table(name = "urkund_submission")
public class UrkundSubmission extends DomainObject {
public enum State {
SUBMISSION_FAILED, SUBMITTED, REJECTED, ACCEPTED, ANALYZED, ERROR;
public boolean isFinal() {
return !(this == SUBMITTED || this == ACCEPTED);
}
}
// ----------------------------------------------------------------------------------
// Basic JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private User receiver;
@Basic
@Column(name = "submitted_date", nullable = false)
private Instant submitted;
@Basic
private String analysisAddress;
@Column(nullable = false)
@Column(name = "state", nullable = false)
@Enumerated(EnumType.STRING)
private State state;
@Column(nullable = false)
private Instant submitted;
@Column(nullable = false)
@Basic
@Column(name = "next_poll_date", nullable = false)
private Instant nextPoll;
@Column(nullable = false)
@Basic
@Column(name = "polling_delay", nullable = false)
@Enumerated(EnumType.STRING)
private PollingDelay pollingDelay = PollingDelay.FIRST;
@OneToOne(optional = false)
@JoinColumn(name = "document_reference_id")
private FileReference document;
@Basic(optional = false)
@Column(name = "message")
private String message;
@Basic
@Column(name = "report_url")
private String reportUrl;
@Basic
@Column(name = "significance")
private Float significance;
@Basic
@Column(name = "analysis_address")
private String analysisAddress;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (urkund_submission) referencing other
// tables.
// ----------------------------------------------------------------------------------
@OneToOne(optional = false)
@JoinColumn(name = "document_file_reference_id", referencedColumnName = "id")
private FileReference document;
@ManyToOne
@JoinColumn(name = "receiver_user_id", referencedColumnName = "id")
private User receiver;
// ----------------------------------------------------------------------------------
// Properties (Getters and Setters)
// ----------------------------------------------------------------------------------
@Override
public Long getId() {
return this.id;
}
public String getAnalysisAddress() {
return this.analysisAddress;
}
public State getState() {
return this.state;
}
public Instant getSubmitted() {
return this.submitted;
}
public FileReference getDocument() {
return this.document;
}
public String getMessage() {
return this.message;
}
public String getReportUrl() {
return this.reportUrl;
}
public Float getSignificance() {
return this.significance;
}
@Override
public String toString() {
return "UrkundSubmission(id=" + this.getId() + ", receiver=" + this.getReceiver() + ", analysisAddress=" + this.getAnalysisAddress() + ", state=" + this.getState() + ", submitted=" + this.getSubmitted() + ", nextPoll=" + this.getNextPoll() + ", pollingDelay=" + this.getPollingDelay() + ", fileDescription=" + this.getDocument() + ", message=" + this.getMessage() + ", reportUrl=" + this.getReportUrl() + ", significance=" + this.getSignificance() + ")";
}
void setId(Long id) {
this.id = id;
}
void setReceiver(User receiver) {
this.receiver = receiver;
}
void setAnalysisAddress(String analysisAddress) {
this.analysisAddress = analysisAddress;
}
void setState(State state) {
this.state = state;
public Instant getSubmitted() {
return this.submitted;
}
void setSubmitted(Instant submitted) {
this.submitted = submitted;
}
public State getState() {
return this.state;
}
void setState(State state) {
this.state = state;
}
Instant getNextPoll() {
return this.nextPoll;
}
void setNextPoll(Instant nextPoll) {
this.nextPoll = nextPoll;
}
PollingDelay getPollingDelay() {
return this.pollingDelay;
}
void setPollingDelay(PollingDelay pollingDelay) {
this.pollingDelay = pollingDelay;
}
void setDocument(FileReference fileDescription) {
this.document = fileDescription;
public String getMessage() {
return this.message;
}
void setMessage(String message) {
this.message = message;
}
public String getReportUrl() {
return this.reportUrl;
}
void setReportUrl(String reportUrl) {
this.reportUrl = reportUrl;
}
public Float getSignificance() {
return this.significance;
}
void setSignificance(Float significance) {
this.significance = significance;
}
public String getAnalysisAddress() {
return this.analysisAddress;
}
void setAnalysisAddress(String analysisAddress) {
this.analysisAddress = analysisAddress;
}
public FileReference getDocument() {
return this.document;
}
void setDocument(FileReference fileDescription) {
this.document = fileDescription;
}
User getReceiver() {
return this.receiver;
}
void setReceiver(User receiver) {
this.receiver = receiver;
}
// ----------------------------------------------------------------------------------
// Methods Common To All Objects
// ----------------------------------------------------------------------------------
@Override
public boolean equals(final Object o) {
if (o == this) return true;
@ -170,10 +190,6 @@ public class UrkundSubmission extends DomainObject {
&& Objects.equals(this.getSignificance(), other.getSignificance());
}
protected boolean canEqual(final Object other) {
return other instanceof UrkundSubmission;
}
@Override
public int hashCode() {
return Objects.hash(
@ -190,15 +206,31 @@ public class UrkundSubmission extends DomainObject {
this.getSignificance());
}
User getReceiver() {
return this.receiver;
@Override
public String toString() {
return "UrkundSubmission(id=" + this.getId() + ", receiver=" + this.getReceiver() +
", analysisAddress=" + this.getAnalysisAddress() + ", state=" +
this.getState() + ", submitted=" + this.getSubmitted() +
", nextPoll=" + this.getNextPoll() + ", pollingDelay=" + this.getPollingDelay() +
", fileDescription=" + this.getDocument() + ", message=" + this.getMessage() +
", reportUrl=" + this.getReportUrl() + ", significance=" + this.getSignificance() + ")";
}
Instant getNextPoll() {
return this.nextPoll;
// ----------------------------------------------------------------------------------
// Other Methods
// ----------------------------------------------------------------------------------
protected boolean canEqual(final Object other) {
return other instanceof UrkundSubmission;
}
PollingDelay getPollingDelay() {
return this.pollingDelay;
// ----------------------------------------------------------------------------------
// Nested type
// ----------------------------------------------------------------------------------
public enum State {
SUBMISSION_FAILED, SUBMITTED, REJECTED, ACCEPTED, ANALYZED, ERROR;
public boolean isFinal() {
return !(this == SUBMITTED || this == ACCEPTED);
}
}
}

View File

@ -2770,6 +2770,58 @@ alter table `decision`
foreign key (reviewer_approval_id) references reviewer_approval (id)
on delete cascade on update cascade;
/*
* Step 19: urkund_submission & plagiarium_request
*/
-- table: urkund_submission
alter table `urkund_submission` drop foreign key `urkund_submission_ibfk_2`;
alter table `urkund_submission` drop foreign key `FK_urkund_submission_document_reference`;
alter table `urkund_submission` drop key `FK_urkund_submission_document_reference`;
alter table `urkund_submission` drop key `FK_urkund_submission_receiver`;
alter table `urkund_submission` change `document_reference_id` `document_file_reference_id` bigint(20) not null;
alter table `urkund_submission` change `receiver_id` `receiver_user_id` bigint(20) not null after `document_file_reference_id`;
alter table `urkund_submission` change `submitted` `submitted_date` datetime not null;
alter table `urkund_submission` change `nextPoll` `next_poll_date` datetime not null;
alter table `urkund_submission` change `pollingDelay` `polling_delay` varchar(16) not null;
alter table `urkund_submission` change `reportUrl` `report_url` varchar(255) default null;
alter table `urkund_submission` change `analysisAddress` `analysis_address` varchar(255) default null;
alter table `urkund_submission`
add constraint fk_urkund_submission_document_file_reference_id
foreign key (document_file_reference_id) references file_reference (id)
on delete cascade on update cascade;
alter table `urkund_submission`
add constraint fk_urkund_submission_receiver_user_id
foreign key (receiver_user_id) references user (id)
on delete cascade on update cascade;
-- table: plagiarism_request
alter table `plagiarism_request` drop foreign key `plagiarism_request_ibfk_2`;
alter table `plagiarism_request` drop foreign key `FK_plagiarism_request_document_reference`;
alter table `plagiarism_request` drop key `FK_plagiarism_request_document_reference`;
alter table `plagiarism_request` drop key `FK_plagiarism_request_receiver`;
alter table `plagiarism_request` change `document_reference_id` `document_file_reference_id` bigint(20) not null;
alter table `plagiarism_request` change `receiver_id` `receiver_user_id` bigint(20) not null after `document_file_reference_id`;
alter table `plagiarism_request`
add constraint fk_plagiarism_request_document_file_reference_id
foreign key (document_file_reference_id) references file_reference (id)
on delete cascade on update cascade;
alter table `plagiarism_request`
add constraint fk_plagiarism_request_receiver_user_id
foreign key (receiver_user_id) references user (id)
on delete cascade on update cascade;
/* Useful SQL
>>> SQL query for FK-to: