|
| 1 | +package edu.tamu.app.model; |
| 2 | + |
| 3 | +import static javax.persistence.CascadeType.MERGE; |
| 4 | +import static javax.persistence.CascadeType.REFRESH; |
| 5 | +import static javax.persistence.FetchType.EAGER; |
| 6 | + |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.Calendar; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +import javax.persistence.Column; |
| 12 | +import javax.persistence.Entity; |
| 13 | +import javax.persistence.JoinColumn; |
| 14 | +import javax.persistence.ManyToMany; |
| 15 | +import javax.persistence.ManyToOne; |
| 16 | +import javax.persistence.Temporal; |
| 17 | +import javax.persistence.TemporalType; |
| 18 | +import javax.validation.constraints.Size; |
| 19 | + |
| 20 | +import org.hibernate.annotations.CreationTimestamp; |
| 21 | +import org.hibernate.annotations.Fetch; |
| 22 | +import org.hibernate.annotations.FetchMode; |
| 23 | +import org.hibernate.annotations.UpdateTimestamp; |
| 24 | + |
| 25 | +import edu.tamu.app.enums.NoteType; |
| 26 | +import edu.tamu.framework.model.BaseEntity; |
| 27 | + |
| 28 | +@Entity |
| 29 | +public class Note extends BaseEntity { |
| 30 | + |
| 31 | + @Size(min = 1) |
| 32 | + @Column(nullable = false) |
| 33 | + private String title; |
| 34 | + |
| 35 | + @Fetch(FetchMode.SELECT) |
| 36 | + @ManyToMany(cascade = { REFRESH, MERGE}, fetch = EAGER) |
| 37 | + private List<Service> services; |
| 38 | + |
| 39 | + private NoteType noteType; |
| 40 | + |
| 41 | + private String body; |
| 42 | + |
| 43 | + @Temporal(TemporalType.DATE) |
| 44 | + private Calendar scheduledPostingStart; |
| 45 | + |
| 46 | + @Temporal(TemporalType.DATE) |
| 47 | + private Calendar scheduledPostingEnd; |
| 48 | + |
| 49 | + @Temporal(TemporalType.TIMESTAMP) |
| 50 | + @UpdateTimestamp |
| 51 | + private Calendar lastModified; |
| 52 | + |
| 53 | + @JoinColumn(nullable = false) |
| 54 | + @ManyToOne(cascade = REFRESH) |
| 55 | + private AppUser author; |
| 56 | + |
| 57 | + public Note() { |
| 58 | + setServices(new ArrayList<Service>()); |
| 59 | + } |
| 60 | + |
| 61 | + public Note(String name, AppUser author) { |
| 62 | + this(); |
| 63 | + setTitle(name); |
| 64 | + setAuthor(author); |
| 65 | + } |
| 66 | + |
| 67 | + public String getTitle() { |
| 68 | + return title; |
| 69 | + } |
| 70 | + |
| 71 | + public void setTitle(String title) { |
| 72 | + this.title = title; |
| 73 | + } |
| 74 | + |
| 75 | + public List<Service> getServices() { |
| 76 | + return services; |
| 77 | + } |
| 78 | + |
| 79 | + public void setServices(List<Service> services) { |
| 80 | + this.services = services; |
| 81 | + } |
| 82 | + |
| 83 | + public NoteType getNoteType() { |
| 84 | + return noteType; |
| 85 | + } |
| 86 | + |
| 87 | + public void setNoteType(NoteType noteType) { |
| 88 | + this.noteType = noteType; |
| 89 | + } |
| 90 | + |
| 91 | + public String getBody() { |
| 92 | + return body; |
| 93 | + } |
| 94 | + |
| 95 | + public void setBody(String body) { |
| 96 | + this.body = body; |
| 97 | + } |
| 98 | + |
| 99 | + public Calendar getScheduledPostingStart() { |
| 100 | + return scheduledPostingStart; |
| 101 | + } |
| 102 | + |
| 103 | + public void setScheduledPostingStart(Calendar scheduledPostingStart) { |
| 104 | + this.scheduledPostingStart = scheduledPostingStart; |
| 105 | + } |
| 106 | + |
| 107 | + public Calendar getScheduledPostingEnd() { |
| 108 | + return scheduledPostingEnd; |
| 109 | + } |
| 110 | + |
| 111 | + public void setScheduledPostingEnd(Calendar scheduledPostingEnd) { |
| 112 | + this.scheduledPostingEnd = scheduledPostingEnd; |
| 113 | + } |
| 114 | + |
| 115 | + public Calendar getLastModified() { |
| 116 | + return lastModified; |
| 117 | + } |
| 118 | + |
| 119 | + public void setLastModified(Calendar lastModified) { |
| 120 | + this.lastModified = lastModified; |
| 121 | + } |
| 122 | + |
| 123 | + public AppUser getAuthor() { |
| 124 | + return author; |
| 125 | + } |
| 126 | + |
| 127 | + public void setAuthor(AppUser author) { |
| 128 | + this.author = author; |
| 129 | + } |
| 130 | +} |
0 commit comments