001: /*
002: * Copyright 2005-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.chart.service.impl;
017:
018: import java.util.ArrayList;
019: import java.util.Collection;
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.bo.user.UniversalUser;
026: import org.kuali.core.util.spring.Cached;
027: import org.kuali.module.chart.bo.Chart;
028: import org.kuali.module.chart.dao.ChartDao;
029: import org.kuali.module.chart.service.ChartService;
030: import org.springframework.transaction.annotation.Transactional;
031:
032: /**
033: * This class is the service implementation for the Chart structure. This is the default, Kuali delivered implementation.
034: */
035: @Transactional
036: public class ChartServiceImpl implements ChartService {
037: protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
038: .getLogger(ChartServiceImpl.class);
039:
040: private ChartDao chartDao;
041:
042: /**
043: * @see org.kuali.module.chart.service.ChartService#getByPrimaryId(java.lang.String)
044: */
045: public Chart getByPrimaryId(String chartOfAccountsCode) {
046: return chartDao.getByPrimaryId(chartOfAccountsCode);
047: }
048:
049: /**
050: *
051: * @see org.kuali.module.chart.service.ChartService#getUniversityChart()
052: */
053: public Chart getUniversityChart() {
054: return chartDao.getUniversityChart();
055: }
056:
057: /**
058: * @see org.kuali.module.chart.service.ChartService#getAllChartCodes()
059: */
060: public List getAllChartCodes() {
061: Collection charts = chartDao.getAll();
062: List chartCodes = new ArrayList();
063: for (Iterator iter = charts.iterator(); iter.hasNext();) {
064: Chart element = (Chart) iter.next();
065: chartCodes.add(element.getChartOfAccountsCode());
066: }
067:
068: return chartCodes;
069: }
070:
071: /**
072: * @see org.kuali.module.chart.service.getReportsToHierarchy()
073: */
074: @Cached
075: public Map<String, String> getReportsToHierarchy() {
076:
077: LOG.debug("getReportsToHierarchy");
078: Map<String, String> reportsToHierarchy = new HashMap();
079:
080: Iterator iter = getAllChartCodes().iterator();
081: while (iter.hasNext()) {
082: Chart chart = (Chart) getByPrimaryId((String) iter.next());
083:
084: if (LOG.isDebugEnabled()) {
085: LOG.debug("adding " + chart.getChartOfAccountsCode()
086: + "-->"
087: + chart.getReportsToChartOfAccountsCode());
088: }
089: reportsToHierarchy.put(chart.getChartOfAccountsCode(),
090: chart.getReportsToChartOfAccountsCode());
091: }
092:
093: return reportsToHierarchy;
094: }
095:
096: /**
097: * @see org.kuali.module.chart.service.ChartService#getChartsThatUserIsResponsibleFor(org.kuali.core.bo.user.KualiUser)
098: */
099: public List getChartsThatUserIsResponsibleFor(
100: UniversalUser universalUser) {
101: if (LOG.isDebugEnabled()) {
102: LOG.debug("retrieving chartsResponsible list for user "
103: + universalUser.getPersonName());
104: }
105:
106: // gets the list of accounts that the user is the Fiscal Officer of
107: List chartList = chartDao
108: .getChartsThatUserIsResponsibleFor(universalUser);
109: if (LOG.isDebugEnabled()) {
110: LOG.debug("retrieved chartsResponsible list for user "
111: + universalUser.getPersonName());
112: }
113: return chartList;
114: }
115:
116: /**
117: * @return Returns the chartDao.
118: */
119: public ChartDao getChartDao() {
120: return chartDao;
121: }
122:
123: /**
124: * @param chartDao The chartDao to set.
125: */
126: public void setChartDao(ChartDao chartDao) {
127: this.chartDao = chartDao;
128: }
129:
130: }
|