001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.labor.service.impl;
017:
018: import java.util.Collection;
019: import java.util.List;
020: import java.util.Map;
021:
022: import org.kuali.core.service.LookupService;
023: import org.kuali.module.labor.bo.AccountStatusBaseFunds;
024: import org.kuali.module.labor.bo.EmployeeFunding;
025: import org.kuali.module.labor.bo.July1PositionFunding;
026: import org.kuali.module.labor.bo.LaborCalculatedSalaryFoundationTracker;
027: import org.kuali.module.labor.dao.LaborCalculatedSalaryFoundationTrackerDao;
028: import org.kuali.module.labor.service.LaborCalculatedSalaryFoundationTrackerService;
029: import org.kuali.module.labor.util.ObjectUtil;
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.module.labor.bo.LaborCalculatedSalaryFoundationTracker
036: */
037: @Transactional
038: public class LaborCalculatedSalaryFoundationTrackerServiceImpl
039: implements LaborCalculatedSalaryFoundationTrackerService {
040: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
041: .getLogger(LaborCalculatedSalaryFoundationTrackerServiceImpl.class);
042:
043: private LaborCalculatedSalaryFoundationTrackerDao laborCalculatedSalaryFoundationTrackerDao;
044: private LookupService lookupService;
045:
046: /**
047: * @see org.kuali.module.labor.service.LaborBaseFundsService#findCSFTracker(java.util.Map, boolean)
048: */
049: public List<LaborCalculatedSalaryFoundationTracker> findCSFTracker(
050: Map fieldValues, boolean isConsolidated) {
051: LOG.info("start findCSFTracker()");
052: return laborCalculatedSalaryFoundationTrackerDao
053: .findCSFTrackers(fieldValues, isConsolidated);
054: }
055:
056: /**
057: * @see org.kuali.module.labor.service.LaborCalculatedSalaryFoundationTrackerService#findCSFTrackerWithJuly1(java.util.Map,
058: * boolean)
059: */
060: public List<LaborCalculatedSalaryFoundationTracker> findCSFTrackerWithJuly1(
061: Map fieldValues, boolean isConsolidated) {
062: LOG.info("start findCSFTrackerWithJuly1()");
063:
064: List<LaborCalculatedSalaryFoundationTracker> CSFTrackerCollection = this
065: .findCSFTracker(fieldValues, isConsolidated);
066: Collection<July1PositionFunding> july1PositionFundings = lookupService
067: .findCollectionBySearch(July1PositionFunding.class,
068: fieldValues);
069: for (July1PositionFunding july1PositionFunding : july1PositionFundings) {
070: LaborCalculatedSalaryFoundationTracker CSFTracker = this
071: .findCSFTracker(CSFTrackerCollection,
072: july1PositionFunding);
073:
074: if (CSFTracker != null) {
075: CSFTracker.setJuly1BudgetAmount(CSFTracker
076: .getJuly1BudgetAmount().add(
077: july1PositionFunding
078: .getJuly1BudgetAmount()));
079: CSFTracker.setJuly1BudgetFteQuantity(CSFTracker
080: .getJuly1BudgetFteQuantity().add(
081: july1PositionFunding
082: .getJuly1BudgetFteQuantity()));
083: CSFTracker.setJuly1BudgetTimePercent(CSFTracker
084: .getJuly1BudgetTimePercent().add(
085: july1PositionFunding
086: .getJuly1BudgetTimePercent()));
087: } else {
088: CSFTracker = new LaborCalculatedSalaryFoundationTracker();
089: ObjectUtil
090: .buildObject(CSFTracker, july1PositionFunding);
091: CSFTrackerCollection.add(CSFTracker);
092: }
093: }
094: return CSFTrackerCollection;
095: }
096:
097: /**
098: * Check if there is a CSF track in the given set that matches the given object
099: *
100: * @param csfTrackerCollection the given set of CSF trackers
101: * @param anotherObject the object to be searched
102: * @return the CSF tracker if there is a CSF track in the given set that matches the given object
103: */
104: private LaborCalculatedSalaryFoundationTracker findCSFTracker(
105: List<LaborCalculatedSalaryFoundationTracker> CSFTrackerCollection,
106: Object anotherObject) {
107: for (LaborCalculatedSalaryFoundationTracker CSFTracker : CSFTrackerCollection) {
108: boolean found = ObjectUtil.compareObject(CSFTracker,
109: anotherObject, CSFTracker.getKeyFieldList());
110: if (found) {
111: return CSFTracker;
112: }
113: }
114: return null;
115: }
116:
117: /**
118: * @see org.kuali.module.labor.service.LaborBaseFundsService#findCSFTrackersAsAccountStatusBaseFunds(java.util.Map, boolean)
119: */
120: public List<AccountStatusBaseFunds> findCSFTrackersAsAccountStatusBaseFunds(
121: Map fieldValues, boolean isConsolidated) {
122: LOG.info("start findCSFTrackersAsAccountStatusBaseFunds()");
123: return laborCalculatedSalaryFoundationTrackerDao
124: .findCSFTrackersAsAccountStatusBaseFunds(fieldValues,
125: isConsolidated);
126: }
127:
128: /**
129: * @see org.kuali.module.labor.service.LaborCalculatedSalaryFoundationTrackerService#findCSFTrackersAsEmployeeFunding(java.util.Map,
130: * boolean)
131: */
132: public List<EmployeeFunding> findCSFTrackersAsEmployeeFunding(
133: Map fieldValues, boolean isConsolidated) {
134: LOG.info("start findCSFTrackersAsEmployeeFunding()");
135: return laborCalculatedSalaryFoundationTrackerDao
136: .findCSFTrackersAsEmployeeFunding(fieldValues,
137: isConsolidated);
138: }
139:
140: /**
141: * Sets the laborCalculatedSalaryFoundationTrackerDao attribute value.
142: *
143: * @param laborCalculatedSalaryFoundationTrackerDao The laborCalculatedSalaryFoundationTrackerDao to set.
144: */
145: public void setLaborCalculatedSalaryFoundationTrackerDao(
146: LaborCalculatedSalaryFoundationTrackerDao laborCalculatedSalaryFoundationTrackerDao) {
147: this .laborCalculatedSalaryFoundationTrackerDao = laborCalculatedSalaryFoundationTrackerDao;
148: }
149:
150: /**
151: * Sets the lookupService attribute value.
152: *
153: * @param lookupService The lookupService to set.
154: */
155: public void setLookupService(LookupService lookupService) {
156: this.lookupService = lookupService;
157: }
158: }
|