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: package org.kuali.module.kra.budget.service.impl;
017:
018: import java.util.ArrayList;
019: import java.util.HashMap;
020: import java.util.Iterator;
021: import java.util.List;
022: import java.util.Map;
023:
024: import org.kuali.core.service.BusinessObjectService;
025: import org.kuali.kfs.KFSPropertyConstants;
026: import org.kuali.module.kra.budget.bo.BudgetNonpersonnel;
027: import org.kuali.module.kra.budget.bo.NonpersonnelCategory;
028: import org.kuali.module.kra.budget.bo.NonpersonnelObjectCode;
029: import org.kuali.module.kra.budget.service.BudgetNonpersonnelService;
030: import org.springframework.transaction.annotation.Transactional;
031:
032: @Transactional
033: public class BudgetNonpersonnelServiceImpl implements
034: BudgetNonpersonnelService {
035:
036: // set up logging
037: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
038: .getLogger(BudgetNonpersonnelServiceImpl.class);
039:
040: private BusinessObjectService businessObjectService;
041:
042: public void refreshNonpersonnelObjectCode(List nonpersonnelItems) {
043: for (Iterator nonpersonnelItem = nonpersonnelItems.iterator(); nonpersonnelItem
044: .hasNext();) {
045: BudgetNonpersonnel budgetNonpersonnel = (BudgetNonpersonnel) nonpersonnelItem
046: .next();
047: budgetNonpersonnel
048: .refreshReferenceObject("nonpersonnelObjectCode");
049: }
050: }
051:
052: public BudgetNonpersonnel findBudgetNonpersonnel(
053: Integer budgetNonpersonnelSequenceNumber,
054: List nonpersonnelItems) {
055: BudgetNonpersonnel budgetNonpersonnel = null;
056:
057: for (Iterator nonpersonnelItemsIter = nonpersonnelItems
058: .iterator(); nonpersonnelItemsIter.hasNext();) {
059: budgetNonpersonnel = (BudgetNonpersonnel) nonpersonnelItemsIter
060: .next();
061:
062: if (budgetNonpersonnelSequenceNumber
063: .equals(budgetNonpersonnel
064: .getBudgetNonpersonnelSequenceNumber())) {
065: break;
066: }
067: }
068:
069: return budgetNonpersonnel;
070: }
071:
072: /**
073: * Returns all nonpersonnel categories
074: *
075: * @throws Exception
076: */
077: public List getAllNonpersonnelCategories() {
078: Map fieldValuesNonpersonnelCategories = new HashMap();
079: fieldValuesNonpersonnelCategories.put(
080: KFSPropertyConstants.ACTIVE, true);
081: List<NonpersonnelCategory> nonpersonnelCategories = new ArrayList<NonpersonnelCategory>(
082: businessObjectService.findMatchingOrderBy(
083: NonpersonnelCategory.class,
084: fieldValuesNonpersonnelCategories,
085: KFSPropertyConstants.SORT_NUMBER, true));
086:
087: for (NonpersonnelCategory nonpersonnelCategory : nonpersonnelCategories) {
088: Map fieldValuesNonpersonnelObjectCodes = new HashMap();
089: fieldValuesNonpersonnelObjectCodes
090: .put(
091: KFSPropertyConstants.BUDGET_NONPERSONNEL_CATEGORY_CODE,
092: nonpersonnelCategory.getCode());
093: fieldValuesNonpersonnelObjectCodes.put(
094: KFSPropertyConstants.ACTIVE, true);
095: nonpersonnelCategory
096: .setNonpersonnelObjectCodes(new ArrayList(
097: businessObjectService
098: .findMatchingOrderBy(
099: NonpersonnelObjectCode.class,
100: fieldValuesNonpersonnelObjectCodes,
101: KFSPropertyConstants.BUDGET_NONPERSONNEL_SUB_CATEGORY_CODE,
102: true)));
103: }
104:
105: return nonpersonnelCategories;
106: }
107:
108: public void setBusinessObjectService(
109: BusinessObjectService businessObjectService) {
110: this.businessObjectService = businessObjectService;
111: }
112: }
|