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