|
| 1 | + |
| 2 | +package edu.harvard.iq.dataverse; |
| 3 | + |
| 4 | +import edu.harvard.iq.dataverse.util.BundleUtil; |
| 5 | +import java.io.Serializable; |
| 6 | +import java.util.Collection; |
| 7 | +import javax.persistence.CascadeType; |
| 8 | +import javax.persistence.Column; |
| 9 | +import javax.persistence.Entity; |
| 10 | +import javax.persistence.GeneratedValue; |
| 11 | +import javax.persistence.GenerationType; |
| 12 | +import javax.persistence.Id; |
| 13 | +import javax.persistence.OneToMany; |
| 14 | + |
| 15 | + |
| 16 | +/** |
| 17 | + * |
| 18 | + * @author skraffmi |
| 19 | + */ |
| 20 | +@Entity |
| 21 | +public class BannerMessage implements Serializable { |
| 22 | + |
| 23 | + @Id |
| 24 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 25 | + private Long id; |
| 26 | + |
| 27 | + @Column |
| 28 | + private boolean dismissibleByUser; |
| 29 | + |
| 30 | + @Column |
| 31 | + private boolean active; |
| 32 | + |
| 33 | + @OneToMany(mappedBy = "bannerMessage", cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}) |
| 34 | + private Collection<BannerMessageText> bannerMessageTexts; |
| 35 | + |
| 36 | + @OneToMany(mappedBy = "bannerMessage", cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}) |
| 37 | + private Collection<UserBannerMessage> userBannerMessages; |
| 38 | + |
| 39 | + public Collection<BannerMessageText> getBannerMessageTexts() { |
| 40 | + return this.bannerMessageTexts; |
| 41 | + } |
| 42 | + |
| 43 | + public void setBannerMessageTexts(Collection<BannerMessageText> bannerMessageTexts) { |
| 44 | + this.bannerMessageTexts = bannerMessageTexts; |
| 45 | + } |
| 46 | + |
| 47 | + |
| 48 | + public String getDisplayValue(){ |
| 49 | + String retVal = ""; |
| 50 | + for (BannerMessageText msgTxt : this.getBannerMessageTexts()) { |
| 51 | + if (msgTxt.getLang().equals(BundleUtil.getCurrentLocale().getLanguage())) { |
| 52 | + retVal = msgTxt.getMessage(); |
| 53 | + } |
| 54 | + } |
| 55 | + return retVal; |
| 56 | + } |
| 57 | + |
| 58 | + public boolean isDismissibleByUser() { |
| 59 | + return dismissibleByUser; |
| 60 | + } |
| 61 | + |
| 62 | + public void setDismissibleByUser(boolean dismissibleByUser) { |
| 63 | + this.dismissibleByUser = dismissibleByUser; |
| 64 | + } |
| 65 | + |
| 66 | + public Long getId() { |
| 67 | + return id; |
| 68 | + } |
| 69 | + |
| 70 | + public void setId(Long id) { |
| 71 | + this.id = id; |
| 72 | + } |
| 73 | + |
| 74 | + public boolean isActive() { |
| 75 | + return active; |
| 76 | + } |
| 77 | + |
| 78 | + public void setActive(boolean active) { |
| 79 | + this.active = active; |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public int hashCode() { |
| 84 | + int hash = 0; |
| 85 | + hash += (id != null ? id.hashCode() : 0); |
| 86 | + return hash; |
| 87 | + } |
| 88 | + |
| 89 | + @Override |
| 90 | + public boolean equals(Object object) { |
| 91 | + // TODO: Warning - this method won't work in the case the id fields are not set |
| 92 | + if (!(object instanceof BannerMessage)) { |
| 93 | + return false; |
| 94 | + } |
| 95 | + BannerMessage other = (BannerMessage) object; |
| 96 | + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { |
| 97 | + return false; |
| 98 | + } |
| 99 | + return true; |
| 100 | + } |
| 101 | + |
| 102 | + @Override |
| 103 | + public String toString() { |
| 104 | + return "edu.harvard.iq.dataverse.BannerMessage[ id=" + id + " ]"; |
| 105 | + } |
| 106 | + |
| 107 | +} |
0 commit comments