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