|
| 1 | +package edu.harvard.iq.dataverse; |
| 2 | + |
| 3 | +import jakarta.persistence.Column; |
| 4 | +import jakarta.persistence.Index; |
| 5 | +import jakarta.persistence.NamedQueries; |
| 6 | +import jakarta.persistence.NamedQuery; |
| 7 | +import jakarta.persistence.Table; |
| 8 | +import java.io.Serializable; |
| 9 | +import jakarta.persistence.Entity; |
| 10 | +import jakarta.persistence.GeneratedValue; |
| 11 | +import jakarta.persistence.GenerationType; |
| 12 | +import jakarta.persistence.Id; |
| 13 | + |
| 14 | +/** |
| 15 | + * |
| 16 | + * @author landreev |
| 17 | + * |
| 18 | + * The name of the class is provisional. I'm open to better-sounding alternatives, |
| 19 | + * if anyone can think of any. |
| 20 | + * But I wanted to avoid having the word "Globus" in the entity name. I'm adding |
| 21 | + * it specifically for the Globus use case. But I'm guessing there's a chance |
| 22 | + * this setup may come in handy for other types of datafile uploads that happen |
| 23 | + * externally. (?) |
| 24 | + */ |
| 25 | +@NamedQueries({ |
| 26 | + @NamedQuery(name = "ExternalFileUploadInProgress.deleteByTaskId", |
| 27 | + query = "DELETE FROM ExternalFileUploadInProgress f WHERE f.taskId=:taskId"), |
| 28 | + @NamedQuery(name = "ExternalFileUploadInProgress.findByTaskId", |
| 29 | + query = "SELECT f FROM ExternalFileUploadInProgress f WHERE f.taskId=:taskId")}) |
| 30 | +@Entity |
| 31 | +@Table(indexes = {@Index(columnList="taskid")}) |
| 32 | +public class ExternalFileUploadInProgress implements Serializable { |
| 33 | + |
| 34 | + private static final long serialVersionUID = 1L; |
| 35 | + @Id |
| 36 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 37 | + private Long id; |
| 38 | + |
| 39 | + public Long getId() { |
| 40 | + return id; |
| 41 | + } |
| 42 | + |
| 43 | + public void setId(Long id) { |
| 44 | + this.id = id; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Rather than saving various individual fields defining the datafile, |
| 49 | + * which would essentially replicate the DataFile table, we are simply |
| 50 | + * storing the full json record as passed to the API here. |
| 51 | + */ |
| 52 | + @Column(columnDefinition = "TEXT", nullable=false) |
| 53 | + private String fileInfo; |
| 54 | + |
| 55 | + /** |
| 56 | + * This is Globus-specific task id associated with the upload in progress |
| 57 | + */ |
| 58 | + @Column(nullable=false) |
| 59 | + private String taskId; |
| 60 | + |
| 61 | + public ExternalFileUploadInProgress() { |
| 62 | + } |
| 63 | + |
| 64 | + public ExternalFileUploadInProgress(String taskId, String fileInfo) { |
| 65 | + this.taskId = taskId; |
| 66 | + this.fileInfo = fileInfo; |
| 67 | + } |
| 68 | + |
| 69 | + public String getFileInfo() { |
| 70 | + return fileInfo; |
| 71 | + } |
| 72 | + |
| 73 | + public void setFileInfo(String fileInfo) { |
| 74 | + this.fileInfo = fileInfo; |
| 75 | + } |
| 76 | + |
| 77 | + public String getTaskId() { |
| 78 | + return taskId; |
| 79 | + } |
| 80 | + |
| 81 | + public void setTaskId(String taskId) { |
| 82 | + this.taskId = taskId; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public int hashCode() { |
| 87 | + int hash = 0; |
| 88 | + hash += (id != null ? id.hashCode() : 0); |
| 89 | + return hash; |
| 90 | + } |
| 91 | + |
| 92 | + @Override |
| 93 | + public boolean equals(Object object) { |
| 94 | + // TODO: Warning - this method won't work in the case the id fields are not set |
| 95 | + if (!(object instanceof ExternalFileUploadInProgress)) { |
| 96 | + return false; |
| 97 | + } |
| 98 | + ExternalFileUploadInProgress other = (ExternalFileUploadInProgress) object; |
| 99 | + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { |
| 100 | + return false; |
| 101 | + } |
| 102 | + return true; |
| 103 | + } |
| 104 | + |
| 105 | + @Override |
| 106 | + public String toString() { |
| 107 | + return "edu.harvard.iq.dataverse.ExternalFileUploadInProgress[ id=" + id + " ]"; |
| 108 | + } |
| 109 | + |
| 110 | +} |
0 commit comments