001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.kuali.kfs.module.ld.businessobject;
018    
019    import org.apache.commons.lang.StringUtils;
020    import org.kuali.kfs.module.ld.LaborConstants;
021    import org.kuali.kfs.sys.context.SpringContext;
022    import org.kuali.rice.kim.bo.Person;
023    import org.kuali.rice.kim.service.PersonService;
024    import org.kuali.rice.kns.util.ObjectUtils;
025    
026    /**
027     * Labor business object for PositionFunding
028     */
029    public class PositionFunding extends LaborCalculatedSalaryFoundationTracker {
030        private Person ledgerPerson;
031    
032        /**
033         * Gets the ledgerPerson.
034         * 
035         * @return Returns the ledgerPerson.
036         */
037        public Person getLedgerPerson() {
038            if(ledgerPerson == null || !StringUtils.equals(ledgerPerson.getEmployeeId(), this.getEmplid())) {
039                ledgerPerson = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(this.getEmplid());
040            }
041            
042            return ledgerPerson;
043        }
044    
045        /**
046         * Sets the ledgerPerson.
047         * 
048         * @param ledgerPerson The ledgerPerson to set.
049         */
050        public void setLedgerPerson(Person ledgerPerson) {
051            this.ledgerPerson = ledgerPerson;
052        }
053    
054        /**
055         * @see org.kuali.kfs.module.ld.businessobject.LaborCalculatedSalaryFoundationTracker#getName()
056         */
057        @Override
058        public String getName() {
059            Person person = this.getLedgerPerson();
060            if (ObjectUtils.isNull(person)) {
061                return LaborConstants.BalanceInquiries.UnknownPersonName;
062            }
063            
064            return person.getName();
065        }
066    }
067