View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.core.principal.web;
17  
18  import java.util.Map;
19  
20  import org.kuali.kpme.core.bo.HrBusinessObject;
21  import org.kuali.kpme.core.bo.HrBusinessObjectMaintainableImpl;
22  import org.kuali.kpme.core.cache.CacheUtils;
23  import org.kuali.kpme.core.principal.PrincipalHRAttributesBo;
24  import org.kuali.kpme.core.service.HrServiceLocator;
25  import org.kuali.kpme.core.util.HrConstants;
26  import org.kuali.rice.kim.api.identity.name.EntityName;
27  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
28  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
29  
30  public class PrincipalHRAttributesMaintainableImpl extends HrBusinessObjectMaintainableImpl {
31  	private static final long serialVersionUID = 1L;
32  
33  	@Override
34  	public void processAfterCopy(MaintenanceDocument document,
35  			Map<String, String[]> parameters) {
36  		super.processAfterCopy(document, parameters);
37  		PrincipalHRAttributesBo principalHRAttributes = (PrincipalHRAttributesBo) document.getNewMaintainableObject().getDataObject();
38  		principalHRAttributes.setPrincipalId(null);
39  	}
40  
41  	@Override
42  	public void saveBusinessObject() {
43  		super.saveBusinessObject();
44  		CacheUtils.flushCache(PrincipalHRAttributesBo.CACHE_NAME);
45  		CacheUtils.flushCache(HrConstants.CacheNamespace.KPME_GLOBAL_CACHE_NAME);
46  	}
47  
48  	@Override
49  	public HrBusinessObject getObjectById(String id) {
50  		return PrincipalHRAttributesBo.from(HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes(id));
51  	}
52  
53      //attribute query, populates name when principalID is selected
54      public EntityName getName(String principalId) {
55          return KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(principalId).getDefaultName();
56      }
57  
58  }