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.cache.CacheUtils;
22 import org.kuali.hr.time.HrBusinessObject;
23 import org.kuali.hr.time.principal.PrincipalHRAttributes;
24 import org.kuali.hr.time.service.base.TkServiceLocator;
25 import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
26 import org.kuali.rice.kim.api.identity.Person;
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 Person p = KimApiServiceLocator.getPersonService().getPerson(
40 fieldValues.get("principalId"));
41 if (p != null) {
42 fieldValues.put("name", p.getName());
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 TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes(id);
60 }
61
62
63 }