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.chart.service.impl;
017:
018: import java.util.Collection;
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.kfs.context.SpringContext;
025: import org.kuali.module.chart.bo.OrganizationReversion;
026: import org.kuali.module.chart.bo.OrganizationReversionCategory;
027: import org.kuali.module.chart.dao.OrganizationReversionDao;
028: import org.kuali.module.chart.service.OrganizationReversionService;
029: import org.kuali.module.gl.service.OrganizationReversionCategoryLogic;
030: import org.kuali.module.gl.service.impl.orgreversion.GenericOrganizationReversionCategory;
031: import org.springframework.transaction.annotation.Transactional;
032:
033: /**
034: *
035: * This service implementation is the default implementation of the OrganizationReversion service that is delivered with Kuali.
036: */
037: @Transactional
038: public class OrganizationReversionServiceImpl implements
039: OrganizationReversionService {
040: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
041: .getLogger(OrganizationReversionServiceImpl.class);
042:
043: private OrganizationReversionDao organizationReversionDao;
044:
045: /**
046: * @see org.kuali.module.chart.service.OrganizationReversionService#getByPrimaryId(java.lang.Integer, java.lang.String,
047: * java.lang.String)
048: */
049: public OrganizationReversion getByPrimaryId(Integer fiscalYear,
050: String chartCode, String orgCode) {
051: LOG.debug("getByPrimaryId() started");
052: return organizationReversionDao.getByPrimaryId(fiscalYear,
053: chartCode, orgCode);
054: }
055:
056: /**
057: * @see org.kuali.module.chart.service.OrganizationReversionService#getCategories()
058: */
059: public Map<String, OrganizationReversionCategoryLogic> getCategories() {
060: LOG.debug("getCategories() started");
061:
062: Map<String, OrganizationReversionCategoryLogic> categories = new HashMap<String, OrganizationReversionCategoryLogic>();
063:
064: Collection cats = organizationReversionDao.getCategories();
065:
066: for (Iterator iter = cats.iterator(); iter.hasNext();) {
067: OrganizationReversionCategory orc = (OrganizationReversionCategory) iter
068: .next();
069:
070: String categoryCode = orc
071: .getOrganizationReversionCategoryCode();
072:
073: Map<String, OrganizationReversionCategoryLogic> beanMap = SpringContext
074: .getBeansOfType(OrganizationReversionCategoryLogic.class);
075: if (beanMap.containsKey("gl" + categoryCode
076: + "OrganizationReversionCategory")) {
077: LOG
078: .info("Found Organization Reversion Category Logic for gl"
079: + categoryCode
080: + "OrganizationReversionCategory");
081: categories.put(categoryCode, beanMap.get("gl"
082: + categoryCode
083: + "OrganizationReversionCategory"));
084: } else {
085: LOG
086: .info("No Organization Reversion Category Logic for gl"
087: + categoryCode
088: + "OrganizationReversionCategory; using generic");
089: GenericOrganizationReversionCategory cat = SpringContext
090: .getBean(GenericOrganizationReversionCategory.class);
091: cat.setCategoryCode(categoryCode);
092: cat.setCategoryName(orc
093: .getOrganizationReversionCategoryName());
094: categories.put(categoryCode,
095: (OrganizationReversionCategoryLogic) cat);
096: }
097: }
098: return categories;
099: }
100:
101: /**
102: *
103: * @see org.kuali.module.chart.service.OrganizationReversionService#getCategoryList()
104: */
105: public List<OrganizationReversionCategory> getCategoryList() {
106: LOG.debug("getCategoryList() started");
107:
108: return organizationReversionDao.getCategories();
109: }
110:
111: /**
112: *
113: * This method injects the OrganizationReversionDao
114: * @param orgDao
115: */
116: public void setOrganizationReversionDao(
117: OrganizationReversionDao orgDao) {
118: organizationReversionDao = orgDao;
119: }
120: }
|