1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.impl.identity.personal |
17 | |
|
18 | |
import javax.persistence.Table |
19 | |
import javax.persistence.Entity |
20 | |
import javax.persistence.GeneratedValue |
21 | |
import javax.persistence.Id |
22 | |
import org.hibernate.annotations.GenericGenerator |
23 | |
import org.hibernate.annotations.Parameter |
24 | |
import javax.persistence.Column |
25 | |
import javax.persistence.Transient |
26 | |
import org.kuali.rice.kim.api.identity.personal.EntityEthnicity |
27 | |
import org.kuali.rice.kim.api.identity.personal.EntityEthnicityContract |
28 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
29 | |
import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences |
30 | |
|
31 | |
import org.kuali.rice.kim.api.KimApiConstants |
32 | |
|
33 | |
@Entity |
34 | |
@Table(name = "KRIM_ENTITY_ETHNIC_T") |
35 | |
class EntityEthnicityBo extends PersistableBusinessObjectBase implements EntityEthnicityContract { |
36 | |
private static final long serialVersionUID = 4870141334376945160L; |
37 | |
|
38 | |
@Id |
39 | |
@GeneratedValue(generator="KRIM_ENTITY_ETHNIC_ID_S") |
40 | |
@GenericGenerator(name="KRIM_ENTITY_ETHNIC_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters=[ |
41 | |
@Parameter(name="sequence_name",value="KRIM_ENTITY_ETHNIC_ID_S"), |
42 | |
@Parameter(name="value_column",value="id") |
43 | |
]) |
44 | |
@Column(name = "ID") |
45 | |
String id |
46 | |
|
47 | |
@Column(name = "ENTITY_ID") |
48 | |
String entityId |
49 | |
|
50 | |
@Column(name = "ETHNCTY_CD") |
51 | |
String ethnicityCode |
52 | |
|
53 | |
@Column(name = "SUB_ETHNCTY_CD") |
54 | |
String subEthnicityCode |
55 | |
|
56 | |
@Transient |
57 | |
boolean suppressPersonal |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
static EntityEthnicity to(EntityEthnicityBo bo) { |
65 | 0 | if (bo == null) { return null } |
66 | 0 | return EntityEthnicity.Builder.create(bo).build() |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
static EntityEthnicityBo from(EntityEthnicity immutable) { |
75 | 0 | if (immutable == null) {return null} |
76 | |
|
77 | 0 | EntityEthnicityBo bo = new EntityEthnicityBo() |
78 | 0 | bo.entityId = immutable.entityId |
79 | 0 | bo.id = immutable.id |
80 | 0 | bo.ethnicityCode = immutable.ethnicityCode |
81 | 0 | bo.subEthnicityCode = immutable.subEthnicityCode |
82 | 0 | bo.versionNumber = immutable.versionNumber |
83 | 0 | bo.objectId = immutable.objectId |
84 | |
|
85 | 0 | return bo; |
86 | |
} |
87 | |
|
88 | |
@Override |
89 | |
boolean isSuppressPersonal() { |
90 | 0 | if (this.suppressPersonal == null) { |
91 | 0 | EntityPrivacyPreferences privacy = KimApiServiceLocator.getIdentityService().getEntityPrivacyPreferences(getEntityId()) |
92 | 0 | if (privacy != null) { |
93 | 0 | this.suppressPersonal = privacy.isSuppressPersonal() |
94 | |
} else { |
95 | 0 | this.suppressPersonal = false |
96 | |
} |
97 | |
} |
98 | |
|
99 | 0 | return suppressPersonal; |
100 | |
} |
101 | |
|
102 | |
@Override |
103 | |
String getEthnicityCode() { |
104 | 0 | if (isSuppressPersonal()) { |
105 | 0 | return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK |
106 | |
} |
107 | 0 | return this.ethnicityCode |
108 | |
} |
109 | |
|
110 | |
@Override |
111 | |
String getSubEthnicityCode() { |
112 | 0 | if (isSuppressPersonal()) { |
113 | 0 | return KimApiConstants.RestrictedMasks.RESTRICTED_DATA_MASK |
114 | |
} |
115 | 0 | return this.subEthnicityCode |
116 | |
} |
117 | |
|
118 | |
@Override |
119 | |
String getEthnicityCodeUnmasked() { |
120 | 0 | return this.ethnicityCode |
121 | |
} |
122 | |
|
123 | |
@Override |
124 | |
String getSubEthnicityCodeUnmasked() { |
125 | 0 | return this.subEthnicityCode |
126 | |
} |
127 | |
} |