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.List;
020: import java.util.SortedSet;
021: import java.util.TreeSet;
022:
023: import org.apache.commons.lang.StringUtils;
024: import org.kuali.module.chart.bo.ObjectCode;
025: import org.kuali.module.chart.dao.ObjectCodeDao;
026: import org.kuali.module.chart.service.ObjectCodeService;
027: import org.kuali.module.financial.service.UniversityDateService;
028: import org.springframework.transaction.annotation.Transactional;
029:
030: /**
031: * This class is the service implementation for the ObjectCode structure. This is the default implementation, that is delivered with
032: * Kuali.
033: */
034: @Transactional
035: public class ObjectCodeServiceImpl implements ObjectCodeService {
036:
037: private ObjectCodeDao objectCodeDao;
038: private UniversityDateService universityDateService;
039:
040: /**
041: *
042: * @see org.kuali.module.chart.service.ObjectCodeService#getByPrimaryId(java.lang.Integer, java.lang.String, java.lang.String)
043: */
044: public ObjectCode getByPrimaryId(Integer universityFiscalYear,
045: String chartOfAccountsCode, String financialObjectCode) {
046: return objectCodeDao.getByPrimaryId(universityFiscalYear,
047: chartOfAccountsCode, financialObjectCode);
048: }
049:
050: /**
051: * @return ObjectCodeDao
052: */
053: public ObjectCodeDao getObjectCodeDao() {
054: return objectCodeDao;
055: }
056:
057: /**
058: * Injects the ObjectCodeDao
059: * @param objectCodeDao
060: */
061: public void setObjectCodeDao(ObjectCodeDao objectCodeDao) {
062: this .objectCodeDao = objectCodeDao;
063: }
064:
065: /**
066: * Gets the universityDateService attribute.
067: *
068: * @return Returns the universityDateService.
069: */
070: public UniversityDateService getUniversityDateService() {
071: return universityDateService;
072: }
073:
074: /**
075: * Sets the universityDateService attribute value.
076: *
077: * @param universityDateService The universityDateService to set.
078: */
079: public void setUniversityDateService(
080: UniversityDateService universityDateService) {
081: this .universityDateService = universityDateService;
082: }
083:
084: /**
085: *
086: * @see org.kuali.module.chart.service.ObjectCodeService#getYearList(java.lang.String, java.lang.String)
087: */
088: public List getYearList(String chartOfAccountsCode,
089: String financialObjectCode) {
090: return objectCodeDao.getYearList(chartOfAccountsCode,
091: financialObjectCode);
092: }
093:
094: /**
095: * @see org.kuali.module.chart.service.ObjectCodeService#getObjectCodeNamesByCharts(java.lang.Integer, java.lang.String[],
096: * java.lang.String)
097: */
098: public String getObjectCodeNamesByCharts(
099: Integer universityFiscalYear, String[] chartOfAccountCodes,
100: String financialObjectCode) {
101: String onlyObjectCodeName = "";
102: SortedSet<String> objectCodeNames = new TreeSet<String>();
103: List<String> objectCodeNameList = new ArrayList<String>();
104: for (String chartOfAccountsCode : chartOfAccountCodes) {
105: ObjectCode objCode = this .getByPrimaryId(
106: universityFiscalYear, chartOfAccountsCode,
107: financialObjectCode);
108: if (objCode != null) {
109: onlyObjectCodeName = objCode
110: .getFinancialObjectCodeName();
111: objectCodeNames.add(objCode
112: .getFinancialObjectCodeName());
113: objectCodeNameList.add(chartOfAccountsCode + ": "
114: + objCode.getFinancialObjectCodeName());
115: } else {
116: onlyObjectCodeName = "Not Found";
117: objectCodeNameList.add(chartOfAccountsCode
118: + ": Not Found");
119: }
120: }
121: if (objectCodeNames.size() > 1) {
122: return StringUtils.join(objectCodeNames.toArray(), ", ");
123: } else {
124: return onlyObjectCodeName;
125: }
126: }
127:
128: /**
129: * @see org.kuali.module.chart.service.ObjectCodeService#getByPrimaryIdForCurrentYear(java.lang.String, java.lang.String)
130: */
131: public ObjectCode getByPrimaryIdForCurrentYear(
132: String chartOfAccountsCode, String financialObjectCode) {
133: return this.getByPrimaryId(universityDateService
134: .getCurrentFiscalYear(), chartOfAccountsCode,
135: financialObjectCode);
136: }
137: }
|