001: /*
002: * Copyright 2006-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:
017: package org.kuali.module.kra.budget.service.impl;
018:
019: import java.util.ArrayList;
020: import java.util.HashMap;
021: import java.util.Iterator;
022: import java.util.List;
023: import java.util.Map;
024:
025: import org.kuali.core.service.BusinessObjectService;
026: import org.kuali.core.util.KualiDecimal;
027: import org.kuali.kfs.KFSConstants;
028: import org.kuali.kfs.KFSPropertyConstants;
029: import org.kuali.module.kra.budget.bo.Budget;
030: import org.kuali.module.kra.budget.bo.BudgetGraduateAssistantRate;
031: import org.kuali.module.kra.budget.bo.GraduateAssistantRate;
032: import org.kuali.module.kra.budget.service.BudgetGraduateAssistantRateService;
033: import org.springframework.transaction.annotation.Transactional;
034:
035: @Transactional
036: public class BudgetGraduateAssistantRateServiceImpl implements
037: BudgetGraduateAssistantRateService {
038:
039: private BusinessObjectService businessObjectService;
040:
041: /**
042: * @see org.kuali.module.kra.budget.service.BudgetGraduateAssistantRateService#getAllGraduateAssistantRates()
043: */
044: public List getAllGraduateAssistantRates() {
045: Map fieldValues = new HashMap();
046: fieldValues.put(KFSPropertyConstants.ACTIVE,
047: KFSConstants.ACTIVE_INDICATOR);
048:
049: return new ArrayList(businessObjectService.findMatching(
050: GraduateAssistantRate.class, fieldValues));
051: }
052:
053: public boolean isValidGraduateAssistantRate(KualiDecimal fringeRate) {
054: return fringeRate == null ? false : fringeRate
055: .isLessEqual(KFSConstants.GRADUATE_ASSISTANT_RATE_MAX);
056: }
057:
058: /**
059: * This method...
060: *
061: * @param budgetForm
062: */
063: public void setupDefaultGradAssistantRates(Budget budget) {
064: for (Iterator iter = getAllGraduateAssistantRates().iterator(); iter
065: .hasNext();) {
066: GraduateAssistantRate graduateAssistantRate = (GraduateAssistantRate) iter
067: .next();
068: BudgetGraduateAssistantRate budgetGraduateAssistantRate = new BudgetGraduateAssistantRate(
069: budget.getDocumentNumber(),
070: graduateAssistantRate.getCampusCode(),
071: graduateAssistantRate.getCampusMaximumPeriod1Rate(),
072: graduateAssistantRate.getCampusMaximumPeriod2Rate(),
073: graduateAssistantRate.getCampusMaximumPeriod3Rate(),
074: graduateAssistantRate.getCampusMaximumPeriod4Rate(),
075: graduateAssistantRate.getCampusMaximumPeriod5Rate(),
076: graduateAssistantRate.getCampusMaximumPeriod6Rate(),
077: graduateAssistantRate);
078: budget.getGraduateAssistantRates().add(
079: budgetGraduateAssistantRate);
080: }
081: }
082:
083: public BudgetGraduateAssistantRate getBudgetGraduateAssistantRate(
084: String documentNumber, String campusCode) {
085:
086: BudgetGraduateAssistantRate budgetGradAsstRate = (BudgetGraduateAssistantRate) businessObjectService
087: .retrieve(new BudgetGraduateAssistantRate(
088: documentNumber, campusCode));
089:
090: if (budgetGradAsstRate == null) {
091: GraduateAssistantRate gradAsstRate = (GraduateAssistantRate) businessObjectService
092: .retrieve(new GraduateAssistantRate(campusCode));
093: budgetGradAsstRate = new BudgetGraduateAssistantRate(
094: documentNumber, gradAsstRate);
095: }
096:
097: return budgetGradAsstRate;
098: }
099:
100: public void setBusinessObjectService(
101: BusinessObjectService businessObjectService) {
102: this.businessObjectService = businessObjectService;
103: }
104: }
|