1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.ui; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.HashMap; |
20 | |
import java.util.LinkedHashMap; |
21 | |
import java.util.List; |
22 | |
import java.util.Map; |
23 | |
|
24 | |
import javax.persistence.Column; |
25 | |
import javax.persistence.Entity; |
26 | |
import javax.persistence.Table; |
27 | |
|
28 | |
import org.apache.log4j.Logger; |
29 | |
import org.kuali.rice.kim.bo.impl.KimAttributes; |
30 | |
import org.kuali.rice.kim.bo.impl.RoleImpl; |
31 | |
import org.kuali.rice.kim.bo.role.impl.RoleResponsibilityImpl; |
32 | |
import org.kuali.rice.kim.bo.types.dto.AttributeDefinitionMap; |
33 | |
import org.kuali.rice.kim.bo.types.dto.KimTypeInfo; |
34 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
35 | |
import org.kuali.rice.kim.service.impl.UiDocumentServiceImpl; |
36 | |
import org.kuali.rice.kim.service.support.KimTypeService; |
37 | |
import org.kuali.rice.kim.util.KimCommonUtils; |
38 | |
import org.kuali.rice.kns.datadictionary.AttributeDefinition; |
39 | |
import org.kuali.rice.kns.util.TypedArrayList; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
@Entity |
48 | |
@Table(name="KRIM_PND_ROLE_MT") |
49 | |
public class PersonDocumentRole extends KimDocumentBoBase { |
50 | 0 | private static final Logger LOG = Logger.getLogger(PersonDocumentRole.class); |
51 | |
private static final long serialVersionUID = 4908044213007222739L; |
52 | |
@Column(name="ROLE_ID") |
53 | |
protected String roleId; |
54 | |
protected String kimTypeId; |
55 | |
protected String roleName; |
56 | |
protected RoleImpl roleImpl; |
57 | |
@Column(name="NMSPC_CD") |
58 | |
protected String namespaceCode; |
59 | |
protected KimTypeInfo kimRoleType; |
60 | |
protected List<? extends KimAttributes> attributes; |
61 | |
protected transient AttributeDefinitionMap definitions; |
62 | |
protected transient Map<String,Object> attributeEntry; |
63 | |
protected List<KimDocumentRoleMember> rolePrncpls; |
64 | |
protected KimDocumentRoleMember newRolePrncpl; |
65 | 0 | protected List<RoleResponsibilityImpl> assignedResponsibilities = new TypedArrayList(RoleResponsibilityImpl.class); |
66 | |
|
67 | 0 | protected boolean isEditable = true; |
68 | |
|
69 | 0 | public PersonDocumentRole() { |
70 | 0 | attributes = new ArrayList<KimAttributes>(); |
71 | 0 | rolePrncpls = new ArrayList<KimDocumentRoleMember>(); |
72 | 0 | attributeEntry = new HashMap<String,Object>(); |
73 | 0 | } |
74 | |
|
75 | |
public String getRoleId() { |
76 | 0 | return this.roleId; |
77 | |
} |
78 | |
|
79 | |
public void setRoleId(String roleId) { |
80 | 0 | this.roleId = roleId; |
81 | 0 | } |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
@SuppressWarnings("unchecked") |
87 | |
@Override |
88 | |
protected LinkedHashMap toStringMapper() { |
89 | 0 | LinkedHashMap m = new LinkedHashMap(); |
90 | 0 | m.put( "roleId", roleId ); |
91 | 0 | return m; |
92 | |
} |
93 | |
|
94 | |
public String getKimTypeId() { |
95 | 0 | return this.kimTypeId; |
96 | |
} |
97 | |
|
98 | |
public void setKimTypeId(String kimTypeId) { |
99 | 0 | this.kimTypeId = kimTypeId; |
100 | 0 | } |
101 | |
|
102 | |
public String getRoleName() { |
103 | 0 | return this.roleName; |
104 | |
} |
105 | |
|
106 | |
public void setRoleName(String roleName) { |
107 | 0 | this.roleName = roleName; |
108 | 0 | } |
109 | |
|
110 | |
public List<? extends KimAttributes> getAttributes() { |
111 | 0 | return this.attributes; |
112 | |
} |
113 | |
|
114 | |
public void setAttributes(List<? extends KimAttributes> attributes) { |
115 | 0 | this.attributes = attributes; |
116 | 0 | } |
117 | |
|
118 | |
public KimTypeInfo getKimRoleType() { |
119 | 0 | if ( kimRoleType == null ) { |
120 | 0 | kimRoleType = KIMServiceLocator.getTypeInfoService().getKimType(kimTypeId); |
121 | |
} |
122 | 0 | return kimRoleType; |
123 | |
} |
124 | |
|
125 | |
@Deprecated |
126 | |
public void setKimRoleType(KimTypeInfo kimRoleType) { |
127 | 0 | this.kimRoleType = kimRoleType; |
128 | 0 | } |
129 | |
|
130 | |
public AttributeDefinitionMap getDefinitionsKeyedByAttributeName() { |
131 | 0 | AttributeDefinitionMap definitionsKeyedBySortCode = getDefinitions(); |
132 | 0 | AttributeDefinitionMap returnValue = new AttributeDefinitionMap(); |
133 | 0 | if (definitionsKeyedBySortCode != null) { |
134 | 0 | for (AttributeDefinition definition : definitionsKeyedBySortCode.values()) { |
135 | 0 | returnValue.put(definition.getName(), definition); |
136 | |
} |
137 | |
} |
138 | 0 | return returnValue; |
139 | |
} |
140 | |
|
141 | |
public AttributeDefinitionMap getDefinitions() { |
142 | 0 | if (definitions == null || definitions.isEmpty()) { |
143 | 0 | KimTypeService kimTypeService = KimCommonUtils.getKimTypeService( this.getKimRoleType() ); |
144 | |
|
145 | |
|
146 | |
try { |
147 | 0 | if ( kimTypeService != null ) { |
148 | 0 | definitions = kimTypeService.getAttributeDefinitions(getKimTypeId()); |
149 | |
} else { |
150 | 0 | definitions = new AttributeDefinitionMap(); |
151 | |
} |
152 | 0 | } catch (Exception ex) { |
153 | 0 | LOG.warn("Not able to retrieve KimTypeService from remote system for KIM Role Type: " + this.getKimRoleType(), ex); |
154 | 0 | } |
155 | |
} |
156 | |
|
157 | 0 | return definitions; |
158 | |
} |
159 | |
|
160 | |
public void setDefinitions(AttributeDefinitionMap definitions) { |
161 | 0 | this.definitions = definitions; |
162 | 0 | } |
163 | |
|
164 | |
public Map<String,Object> getAttributeEntry() { |
165 | 0 | if (attributeEntry == null || attributeEntry.isEmpty()) { |
166 | 0 | attributeEntry = KIMServiceLocator.getUiDocumentService().getAttributeEntries(getDefinitions()); |
167 | |
} |
168 | |
|
169 | 0 | return this.attributeEntry; |
170 | |
} |
171 | |
|
172 | |
public void setAttributeEntry(Map<String,Object> attributeEntry) { |
173 | 0 | this.attributeEntry = attributeEntry; |
174 | 0 | } |
175 | |
|
176 | |
public List<KimDocumentRoleMember> getRolePrncpls() { |
177 | 0 | return this.rolePrncpls; |
178 | |
} |
179 | |
|
180 | |
public void setRolePrncpls(List<KimDocumentRoleMember> rolePrncpls) { |
181 | 0 | this.rolePrncpls = rolePrncpls; |
182 | 0 | } |
183 | |
|
184 | |
public KimDocumentRoleMember getNewRolePrncpl() { |
185 | 0 | return this.newRolePrncpl; |
186 | |
} |
187 | |
|
188 | |
public void setNewRolePrncpl(KimDocumentRoleMember newRolePrncpl) { |
189 | 0 | this.newRolePrncpl = newRolePrncpl; |
190 | 0 | } |
191 | |
|
192 | |
public String getNamespaceCode() { |
193 | 0 | return this.namespaceCode; |
194 | |
} |
195 | |
|
196 | |
public void setNamespaceCode(String namespaceCode) { |
197 | 0 | this.namespaceCode = namespaceCode; |
198 | 0 | } |
199 | |
|
200 | |
public List<RoleResponsibilityImpl> getAssignedResponsibilities() { |
201 | 0 | return this.assignedResponsibilities; |
202 | |
} |
203 | |
|
204 | |
public void setAssignedResponsibilities( |
205 | |
List<RoleResponsibilityImpl> assignedResponsibilities) { |
206 | 0 | this.assignedResponsibilities = assignedResponsibilities; |
207 | 0 | } |
208 | |
|
209 | |
@Override |
210 | |
public boolean isActive(){ |
211 | 0 | return this.active; |
212 | |
} |
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
public RoleImpl getRoleImpl() { |
218 | 0 | return this.roleImpl; |
219 | |
} |
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
public void setRoleImpl(RoleImpl roleImpl) { |
225 | 0 | this.roleImpl = roleImpl; |
226 | 0 | } |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
public boolean isEditable() { |
232 | 0 | return this.isEditable; |
233 | |
} |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
public void setEditable(boolean isEditable) { |
239 | 0 | this.isEditable = isEditable; |
240 | 0 | } |
241 | |
|
242 | |
} |