1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.principal.web;
17
18 import java.util.Map;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.kpme.core.bo.HrBusinessObject;
22 import org.kuali.kpme.core.bo.HrBusinessObjectMaintainableImpl;
23 import org.kuali.kpme.core.cache.CacheUtils;
24 import org.kuali.kpme.core.principal.PrincipalHRAttributes;
25 import org.kuali.kpme.core.service.HrServiceLocator;
26 import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName;
27 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
28 import org.kuali.rice.kns.document.MaintenanceDocument;
29
30 public class PrincipalHRAttributesMaintainableImpl extends HrBusinessObjectMaintainableImpl {
31 private static final long serialVersionUID = 1L;
32
33 @SuppressWarnings("rawtypes")
34 @Override
35 public Map populateBusinessObject(Map<String, String> fieldValues,
36 MaintenanceDocument maintenanceDocument, String methodToCall) {
37 if (fieldValues.containsKey("principalId")
38 && StringUtils.isNotEmpty(fieldValues.get("principalId"))) {
39 EntityNamePrincipalName p = KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(fieldValues.get("principalId"));
40 if (p != null
41 && p.getDefaultName() != null) {
42 fieldValues.put("name", p.getDefaultName().getCompositeName());
43 }else{
44 fieldValues.put("name", "");
45 }
46 }
47 return super.populateBusinessObject(fieldValues, maintenanceDocument,
48 methodToCall);
49 }
50
51 @Override
52 public void saveBusinessObject() {
53 super.saveBusinessObject();
54 CacheUtils.flushCache(PrincipalHRAttributes.CACHE_NAME);
55 }
56
57 @Override
58 public HrBusinessObject getObjectById(String id) {
59 return HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes(id);
60 }
61
62
63 }