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.ld.service.impl; 017 018 import java.util.Collection; 019 import java.util.List; 020 import java.util.Map; 021 022 import org.kuali.kfs.module.ld.businessobject.AccountStatusBaseFunds; 023 import org.kuali.kfs.module.ld.businessobject.EmployeeFunding; 024 import org.kuali.kfs.module.ld.businessobject.July1PositionFunding; 025 import org.kuali.kfs.module.ld.businessobject.LaborCalculatedSalaryFoundationTracker; 026 import org.kuali.kfs.module.ld.dataaccess.LaborCalculatedSalaryFoundationTrackerDao; 027 import org.kuali.kfs.module.ld.service.LaborCalculatedSalaryFoundationTrackerService; 028 import org.kuali.kfs.sys.ObjectUtil; 029 import org.kuali.rice.kns.service.LookupService; 030 import org.springframework.transaction.annotation.Transactional; 031 032 /** 033 * This class provides its clients with access to CSF tracker entries in the backend data store. 034 * 035 * @see org.kuali.kfs.module.ld.businessobject.LaborCalculatedSalaryFoundationTracker 036 */ 037 @Transactional 038 public class LaborCalculatedSalaryFoundationTrackerServiceImpl implements LaborCalculatedSalaryFoundationTrackerService { 039 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LaborCalculatedSalaryFoundationTrackerServiceImpl.class); 040 041 private LaborCalculatedSalaryFoundationTrackerDao laborCalculatedSalaryFoundationTrackerDao; 042 private LookupService lookupService; 043 044 /** 045 * @see org.kuali.kfs.module.ld.service.LaborBaseFundsService#findCSFTracker(java.util.Map, boolean) 046 */ 047 public List<LaborCalculatedSalaryFoundationTracker> findCSFTracker(Map fieldValues, boolean isConsolidated) { 048 LOG.info("start findCSFTracker()"); 049 return laborCalculatedSalaryFoundationTrackerDao.findCSFTrackers(fieldValues, isConsolidated); 050 } 051 052 /** 053 * @see org.kuali.kfs.module.ld.service.LaborCalculatedSalaryFoundationTrackerService#findCSFTrackerWithJuly1(java.util.Map, 054 * boolean) 055 */ 056 public List<LaborCalculatedSalaryFoundationTracker> findCSFTrackerWithJuly1(Map fieldValues, boolean isConsolidated) { 057 LOG.info("start findCSFTrackerWithJuly1()"); 058 059 List<LaborCalculatedSalaryFoundationTracker> CSFTrackerCollection = this.findCSFTracker(fieldValues, isConsolidated); 060 Collection<July1PositionFunding> july1PositionFundings = lookupService.findCollectionBySearch(July1PositionFunding.class, fieldValues); 061 for (July1PositionFunding july1PositionFunding : july1PositionFundings) { 062 LaborCalculatedSalaryFoundationTracker CSFTracker = this.findCSFTracker(CSFTrackerCollection, july1PositionFunding); 063 064 if (CSFTracker != null) { 065 CSFTracker.setJuly1BudgetAmount(CSFTracker.getJuly1BudgetAmount().add(july1PositionFunding.getJuly1BudgetAmount())); 066 CSFTracker.setJuly1BudgetFteQuantity(CSFTracker.getJuly1BudgetFteQuantity().add(july1PositionFunding.getJuly1BudgetFteQuantity())); 067 CSFTracker.setJuly1BudgetTimePercent(CSFTracker.getJuly1BudgetTimePercent().add(july1PositionFunding.getJuly1BudgetTimePercent())); 068 } 069 else { 070 CSFTracker = new LaborCalculatedSalaryFoundationTracker(); 071 ObjectUtil.buildObject(CSFTracker, july1PositionFunding); 072 CSFTrackerCollection.add(CSFTracker); 073 } 074 } 075 return CSFTrackerCollection; 076 } 077 078 /** 079 * Check if there is a CSF track in the given set that matches the given object 080 * 081 * @param csfTrackerCollection the given set of CSF trackers 082 * @param anotherObject the object to be searched 083 * @return the CSF tracker if there is a CSF track in the given set that matches the given object 084 */ 085 protected LaborCalculatedSalaryFoundationTracker findCSFTracker(List<LaborCalculatedSalaryFoundationTracker> CSFTrackerCollection, Object anotherObject) { 086 for (LaborCalculatedSalaryFoundationTracker CSFTracker : CSFTrackerCollection) { 087 boolean found = ObjectUtil.equals(CSFTracker, anotherObject, CSFTracker.getKeyFieldList()); 088 if (found) { 089 return CSFTracker; 090 } 091 } 092 return null; 093 } 094 095 /** 096 * @see org.kuali.kfs.module.ld.service.LaborBaseFundsService#findCSFTrackersAsAccountStatusBaseFunds(java.util.Map, boolean) 097 */ 098 public List<AccountStatusBaseFunds> findCSFTrackersAsAccountStatusBaseFunds(Map fieldValues, boolean isConsolidated) { 099 LOG.info("start findCSFTrackersAsAccountStatusBaseFunds()"); 100 return laborCalculatedSalaryFoundationTrackerDao.findCSFTrackersAsAccountStatusBaseFunds(fieldValues, isConsolidated); 101 } 102 103 /** 104 * @see org.kuali.kfs.module.ld.service.LaborCalculatedSalaryFoundationTrackerService#findCSFTrackersAsEmployeeFunding(java.util.Map, 105 * boolean) 106 */ 107 public List<EmployeeFunding> findCSFTrackersAsEmployeeFunding(Map fieldValues, boolean isConsolidated) { 108 LOG.info("start findCSFTrackersAsEmployeeFunding()"); 109 return laborCalculatedSalaryFoundationTrackerDao.findCSFTrackersAsEmployeeFunding(fieldValues, isConsolidated); 110 } 111 112 /** 113 * Sets the laborCalculatedSalaryFoundationTrackerDao attribute value. 114 * 115 * @param laborCalculatedSalaryFoundationTrackerDao The laborCalculatedSalaryFoundationTrackerDao to set. 116 */ 117 public void setLaborCalculatedSalaryFoundationTrackerDao(LaborCalculatedSalaryFoundationTrackerDao laborCalculatedSalaryFoundationTrackerDao) { 118 this.laborCalculatedSalaryFoundationTrackerDao = laborCalculatedSalaryFoundationTrackerDao; 119 } 120 121 /** 122 * Sets the lookupService attribute value. 123 * 124 * @param lookupService The lookupService to set. 125 */ 126 public void setLookupService(LookupService lookupService) { 127 this.lookupService = lookupService; 128 } 129 }