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    package org.kuali.kfs.module.bc.service.impl;
017    
018    import org.kuali.kfs.module.bc.BCConstants.SynchronizationCheckType;
019    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionIntendedIncumbent;
020    import org.kuali.kfs.module.bc.businessobject.Incumbent;
021    import org.kuali.kfs.module.bc.businessobject.Position;
022    import org.kuali.kfs.module.bc.dataaccess.HumanResourcesPayrollDao;
023    import org.kuali.kfs.module.bc.exception.IncumbentNotFoundException;
024    import org.kuali.kfs.module.bc.exception.PositionNotFoundException;
025    import org.kuali.kfs.module.bc.service.HumanResourcesPayrollService;
026    import org.kuali.kfs.sys.context.SpringContext;
027    import org.kuali.kfs.sys.service.NonTransactional;
028    import org.kuali.rice.kim.bo.Person;
029    import org.kuali.rice.kim.service.PersonService;
030    import org.springframework.transaction.annotation.Transactional;
031    
032    /**
033     * Bootstrap implementation of HumanResourcesPayrollService. Only implements the methods so that Budget will function. Data is not
034     * correct and should not be used in production.
035     * 
036     * @see org.kuali.kfs.module.bc.service.HumanResourcesPayrollService
037     */
038    public class HumanResourcesPayrollServiceImpl implements HumanResourcesPayrollService {
039        HumanResourcesPayrollDao humanResourcesPayrollDao;
040        private PersonService<Person> personService;
041        
042        /**
043         * This is just a bootstrap implementation. Should be replaced by the real integration with the payroll/hr system.
044         * 
045         * @see org.kuali.kfs.module.bc.service.HumanResourcesPayrollService#validatePositionUnionCode(java.lang.String)
046         */
047        @NonTransactional
048        public boolean validatePositionUnionCode(String positionUnionCode) {
049            return true;
050        }
051    
052        /**
053         * This is just a bootstrap implementation. Should be replaced by the real integration with the payroll/hr system.
054         * 
055         * @see org.kuali.kfs.module.bc.service.HumanResourcesPayrollService#getPosition(java.lang.Integer, java.lang.String)
056         */
057        @Transactional
058        public Position getPosition(Integer universityFiscalYear, String positionNumber) throws PositionNotFoundException {
059            Position position = humanResourcesPayrollDao.getPosition(universityFiscalYear, positionNumber);
060    
061            if (position == null) {
062                throw new PositionNotFoundException(universityFiscalYear, positionNumber);
063            }
064    
065            return position;
066        }
067    
068        /**
069         * This is just a bootstrap implementation. Should be replaced by the real integration with the payroll/hr system.
070         * 
071         * @see org.kuali.kfs.module.bc.service.HumanResourcesPayrollService#getIncumbent(java.lang.String)
072         */
073        @Transactional
074        public Incumbent getIncumbent(String emplid) throws IncumbentNotFoundException {
075            Person user = (Person) getPersonService().getPersonByEmployeeId(emplid);
076    
077            if (user == null) {
078                throw new IncumbentNotFoundException(emplid);
079            }
080    
081            Incumbent incumbent = new BudgetConstructionIntendedIncumbent();
082            incumbent.setEmplid(emplid);
083            incumbent.setName(user.getName());
084    
085            return incumbent;
086        }
087    
088        /**
089         * @see org.kuali.kfs.module.bc.service.HumanResourcesPayrollService#isActiveJob(java.lang.String, java.lang.String,
090         *      java.lang.Integer, org.kuali.kfs.module.bc.BCConstants.SynchronizationCheckType)
091         */
092        @Transactional
093        public boolean isActiveJob(String emplid, String positionNumber, Integer fiscalYear, SynchronizationCheckType synchronizationCheckType) {
094            return true;
095        }
096    
097        /**
098         * Sets the humanResourcesPayrollDao attribute value.
099         * 
100         * @param humanResourcesPayrollDao The humanResourcesPayrollDao to set.
101         */
102        @NonTransactional
103        public void setHumanResourcesPayrollDao(HumanResourcesPayrollDao humanResourcesPayrollDao) {
104            this.humanResourcesPayrollDao = humanResourcesPayrollDao;
105        }
106    
107        /**
108         * @return Returns the personService.
109         */
110        protected PersonService<Person> getPersonService() {
111            if(personService==null)
112                personService = SpringContext.getBean(PersonService.class);
113            return personService;
114        }
115    
116    }