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.edo.candidate.maintenance;
17  
18  import org.kuali.kpme.core.bo.HrBusinessObject;
19  import org.kuali.kpme.core.bo.HrBusinessObjectMaintainableImpl;
20  import org.kuali.kpme.edo.candidate.EdoCandidateBo;
21  import org.kuali.kpme.edo.service.EdoServiceLocator;
22  import org.kuali.rice.kim.api.identity.Person;
23  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
24  
25  public class EdoCandidateMaintainableImpl extends HrBusinessObjectMaintainableImpl {
26  	
27  	private static final long serialVersionUID = 1L;
28  
29  	@Override
30  	public HrBusinessObject getObjectById(String id) {
31  		return EdoCandidateBo.from(EdoServiceLocator.getCandidateService().getCandidate(id));
32  	}
33  	
34  	//attribute query, populates firstName and lastName when principalName is selected, for new edoCandidate
35      public EdoCandidateBo getEdoCandidateInfo(String principalName) {
36      	EdoCandidateBo aNewEdoCandidateBo = new EdoCandidateBo();
37  
38      	Person person = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(principalName);
39      	
40          if (person != null && person.getFirstName() != null) {
41          	aNewEdoCandidateBo.setFirstName(person.getFirstName());
42          }else{
43          	aNewEdoCandidateBo.setFirstName("");
44          }
45  
46          if (person != null && person.getLastName() != null) {
47          	aNewEdoCandidateBo.setLastName(person.getLastName());
48          }else{
49          	aNewEdoCandidateBo.setLastName("");
50          }
51          
52          if (person != null && person.getPrimaryDepartmentCode() != null) {
53          	aNewEdoCandidateBo.setPrimaryDeptId(person.getPrimaryDepartmentCode());
54          }else{
55          	aNewEdoCandidateBo.setPrimaryDeptId("");
56          }
57  
58          if (person != null && person.getPrimaryDepartmentCode() != null) {
59          	aNewEdoCandidateBo.setTnpDeptId(person.getPrimaryDepartmentCode());
60          }else{
61          	aNewEdoCandidateBo.setTnpDeptId("");
62          }
63          
64          return aNewEdoCandidateBo;
65      }
66  
67  }