01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.gl.service.impl;
17:
18: import java.util.Iterator;
19:
20: import org.kuali.module.chart.bo.Account;
21: import org.kuali.module.chart.service.AccountService;
22: import org.kuali.module.gl.bo.SufficientFundRebuild;
23: import org.kuali.module.gl.dao.SufficientFundRebuildDao;
24: import org.kuali.module.gl.service.SufficientFundsSyncService;
25: import org.springframework.transaction.annotation.Transactional;
26:
27: /**
28: * The base implementation of SufficientFundsSyncService
29: */
30: @Transactional
31: public class SufficientFundsSyncServiceImpl implements
32: SufficientFundsSyncService {
33: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
34: .getLogger(SufficientFundsSyncServiceImpl.class);
35:
36: private AccountService accountService;
37: private SufficientFundRebuildDao sufficientFundRebuildDao;
38:
39: /**
40: * Goes through all accounts in the database, and generates a sufficient fund rebuild record for each one!
41: * @see org.kuali.module.gl.service.SufficientFundsSyncService#syncSufficientFunds()
42: */
43: public void syncSufficientFunds() {
44: LOG.debug("syncSufficientFunds() started");
45:
46: Iterator i = accountService.getAllAccounts();
47: while (i.hasNext()) {
48: Account a = (Account) i.next();
49: SufficientFundRebuild sfr = sufficientFundRebuildDao
50: .getByAccount(a.getChartOfAccountsCode(), a
51: .getAccountNumber());
52: if (sfr == null) {
53: sfr = new SufficientFundRebuild();
54: sfr.setAccountFinancialObjectTypeCode("A");
55: sfr.setAccountNumberFinancialObjectCode(a
56: .getAccountNumber());
57: sfr.setChartOfAccountsCode(a.getChartOfAccountsCode());
58: sufficientFundRebuildDao.save(sfr);
59: }
60: }
61: }
62:
63: public void setSufficientFundRebuildDao(SufficientFundRebuildDao sfd) {
64: sufficientFundRebuildDao = sfd;
65: }
66:
67: public void setAccountService(AccountService as) {
68: accountService = as;
69: }
70: }
|