1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.entity.impl; |
17 | |
|
18 | |
import java.util.LinkedHashMap; |
19 | |
|
20 | |
import javax.persistence.Column; |
21 | |
import javax.persistence.Entity; |
22 | |
import javax.persistence.FetchType; |
23 | |
import javax.persistence.Id; |
24 | |
import javax.persistence.JoinColumn; |
25 | |
import javax.persistence.ManyToOne; |
26 | |
import javax.persistence.Table; |
27 | |
import javax.persistence.Transient; |
28 | |
|
29 | |
import org.kuali.rice.kim.bo.entity.KimEntityEmail; |
30 | |
import org.kuali.rice.kim.bo.entity.KimEntityPrivacyPreferences; |
31 | |
import org.kuali.rice.kim.bo.reference.EmailType; |
32 | |
import org.kuali.rice.kim.bo.reference.impl.EmailTypeImpl; |
33 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
34 | |
import org.kuali.rice.kim.util.KimCommonUtils; |
35 | |
import org.kuali.rice.kim.util.KimConstants; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@Entity |
41 | |
@Table(name = "KRIM_ENTITY_EMAIL_T") |
42 | 0 | public class KimEntityEmailImpl extends KimDefaultableEntityDataBase implements KimEntityEmail { |
43 | |
|
44 | |
private static final long serialVersionUID = 1L; |
45 | |
|
46 | |
@Id |
47 | |
@Column(name = "ENTITY_EMAIL_ID") |
48 | |
protected String entityEmailId; |
49 | |
|
50 | |
@Column(name = "ENTITY_ID") |
51 | |
protected String entityId; |
52 | |
|
53 | |
@Column(name = "ENT_TYP_CD") |
54 | |
protected String entityTypeCode; |
55 | |
|
56 | |
@Column(name = "EMAIL_TYP_CD") |
57 | |
protected String emailTypeCode; |
58 | |
|
59 | |
@Column(name = "EMAIL_ADDR") |
60 | |
protected String emailAddress; |
61 | |
|
62 | |
@ManyToOne(targetEntity=EmailTypeImpl.class, fetch = FetchType.EAGER, cascade = {}) |
63 | |
@JoinColumn(name = "EMAIL_TYP_CD", insertable = false, updatable = false) |
64 | |
protected EmailType emailType; |
65 | |
|
66 | |
@Transient |
67 | |
protected Boolean suppressEmail; |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public String getEmailAddress() { |
73 | 0 | if (isSuppressEmail()) { |
74 | 0 | return KimConstants.RESTRICTED_DATA_MASK; |
75 | |
} |
76 | 0 | return emailAddress; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public String getEmailTypeCode() { |
83 | 0 | return emailTypeCode; |
84 | |
} |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
public String getEntityEmailId() { |
90 | 0 | return entityEmailId; |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
public void setEmailAddress(String emailAddress) { |
97 | 0 | this.emailAddress = emailAddress; |
98 | 0 | } |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public void setEmailTypeCode(String emailTypeCode) { |
104 | 0 | this.emailTypeCode = emailTypeCode; |
105 | 0 | } |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public String getEntityTypeCode() { |
111 | 0 | return entityTypeCode; |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
public void setEntityTypeCode(String entityTypeCode) { |
118 | 0 | this.entityTypeCode = entityTypeCode; |
119 | 0 | } |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
@Override |
125 | |
protected LinkedHashMap toStringMapper() { |
126 | 0 | LinkedHashMap m = new LinkedHashMap(); |
127 | 0 | m.put("entityEmailId", entityEmailId); |
128 | 0 | m.put("entityTypeCode", entityTypeCode); |
129 | 0 | m.put("emailTypeCode", emailTypeCode); |
130 | 0 | return m; |
131 | |
} |
132 | |
|
133 | |
public String getEntityId() { |
134 | 0 | return this.entityId; |
135 | |
} |
136 | |
|
137 | |
public void setEntityId(String entityId) { |
138 | 0 | this.entityId = entityId; |
139 | 0 | } |
140 | |
|
141 | |
public void setEntityEmailId(String entityEmailId) { |
142 | 0 | this.entityEmailId = entityEmailId; |
143 | 0 | } |
144 | |
|
145 | |
public EmailType getEmailType() { |
146 | 0 | return this.emailType; |
147 | |
} |
148 | |
|
149 | |
public void setEmailType(EmailType emailType) { |
150 | 0 | this.emailType = emailType; |
151 | 0 | } |
152 | |
|
153 | |
public boolean isSuppressEmail() { |
154 | 0 | if (suppressEmail != null) { |
155 | 0 | return suppressEmail.booleanValue(); |
156 | |
} |
157 | 0 | KimEntityPrivacyPreferences privacy = KIMServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId()); |
158 | |
|
159 | 0 | suppressEmail = false; |
160 | 0 | if (privacy != null) { |
161 | 0 | suppressEmail = privacy.isSuppressEmail(); |
162 | |
} |
163 | 0 | return suppressEmail.booleanValue(); |
164 | |
} |
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
public String getEmailAddressUnmasked() { |
170 | 0 | return this.emailAddress; |
171 | |
} |
172 | |
|
173 | |
} |