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.List;
019:
020: import org.apache.commons.lang.StringUtils;
021: import org.kuali.core.util.spring.Cached;
022: import org.kuali.kfs.KFSConstants.ChartApcParms;
023: import org.kuali.kfs.context.SpringContext;
024: import org.kuali.kfs.service.ParameterService;
025: import org.kuali.module.chart.bo.Org;
026: import org.kuali.module.chart.dao.OrganizationDao;
027: import org.kuali.module.chart.service.ChartService;
028: import org.kuali.module.chart.service.OrganizationService;
029: import org.springframework.transaction.annotation.Transactional;
030:
031: /**
032: * This class is the service implementation for the Org structure. This is the default implementation, that is delivered with Kuali.
033: */
034: @Transactional
035: public class OrganizationServiceImpl implements OrganizationService {
036: private OrganizationDao organizationDao;
037: private ParameterService parameterService;
038: private ChartService chartService;
039:
040: /**
041: *
042: * @see org.kuali.module.chart.service.OrganizationService#getByPrimaryId(java.lang.String, java.lang.String)
043: */
044: public Org getByPrimaryId(String chartOfAccountsCode,
045: String organizationCode) {
046: return organizationDao.getByPrimaryId(chartOfAccountsCode,
047: organizationCode);
048: }
049:
050: /**
051: * Implements the getByPrimaryId method defined by OrganizationService. Method is used by KualiOrgReviewAttribute to enable
052: * caching of orgs for routing.
053: *
054: * @see org.kuali.module.chart.service.impl.OrganizationServiceImpl#getByPrimaryId(java.lang.String, java.lang.String)
055: */
056: @Cached
057: public Org getByPrimaryIdWithCaching(String chartOfAccountsCode,
058: String organizationCode) {
059: return organizationDao.getByPrimaryId(chartOfAccountsCode,
060: organizationCode);
061: }
062:
063: /**
064: * Implements the save() method defined by OrganizationService, including validation of the Org BO
065: * @see org.kuali.module.chart.service.OrganizationService#save(org.kuali.module.chart.bo.Org)
066: */
067: public void save(Org organization) {
068: organizationDao.save(organization);
069: }
070:
071: /**
072: * @see org.kuali.module.chart.service.OrganizationService#getActiveAccountsByOrg(java.lang.String, java.lang.String)
073: */
074: public List getActiveAccountsByOrg(String chartOfAccountsCode,
075: String organizationCode) {
076:
077: if (StringUtils.isBlank(chartOfAccountsCode)) {
078: throw new IllegalArgumentException(
079: "String parameter chartOfAccountsCode was null or blank.");
080: }
081: if (StringUtils.isBlank(organizationCode)) {
082: throw new IllegalArgumentException(
083: "String parameter organizationCode was null or blank.");
084: }
085:
086: return organizationDao.getActiveAccountsByOrg(
087: chartOfAccountsCode, organizationCode);
088: }
089:
090: /**
091: * @see org.kuali.module.chart.service.OrganizationService#getActiveChildOrgs(java.lang.String, java.lang.String)
092: */
093: public List getActiveChildOrgs(String chartOfAccountsCode,
094: String organizationCode) {
095:
096: if (StringUtils.isBlank(chartOfAccountsCode)) {
097: throw new IllegalArgumentException(
098: "String parameter chartOfAccountsCode was null or blank.");
099: }
100: if (StringUtils.isBlank(organizationCode)) {
101: throw new IllegalArgumentException(
102: "String parameter organizationCode was null or blank.");
103: }
104:
105: return organizationDao.getActiveChildOrgs(chartOfAccountsCode,
106: organizationCode);
107: }
108:
109: /**
110: *
111: * @see org.kuali.module.chart.service.OrganizationService#getActiveOrgsByType(java.lang.String)
112: */
113: public List<Org> getActiveOrgsByType(String organizationTypeCode) {
114: if (StringUtils.isBlank(organizationTypeCode)) {
115: throw new IllegalArgumentException(
116: "String parameter organizationTypeCode was null or blank.");
117: }
118:
119: return organizationDao
120: .getActiveOrgsByType(organizationTypeCode);
121: }
122:
123: /**
124: *
125: * @see org.kuali.module.chart.service.OrganizationService#getRootOrganizationCode()
126: */
127: public String[] getRootOrganizationCode() {
128: String rootChart = getChartService().getUniversityChart()
129: .getChartOfAccountsCode();
130: String selfReportsOrgType = SpringContext.getBean(
131: ParameterService.class).getParameterValue(Org.class,
132: ChartApcParms.ORG_MUST_REPORT_TO_SELF_ORG_TYPES);
133: return (organizationDao.getRootOrganizationCode(rootChart,
134: selfReportsOrgType));
135: }
136:
137: public void setParameterService(ParameterService parameterService) {
138: this .parameterService = parameterService;
139: }
140:
141: public ChartService getChartService() {
142: return chartService;
143: }
144:
145: public void setChartService(ChartService chartService) {
146: this .chartService = chartService;
147: }
148:
149: /**
150: * @return Returns the organizationDao.
151: */
152: public OrganizationDao getOrganizationDao() {
153: return organizationDao;
154: }
155:
156: /**
157: * @param organizationDao The organizationDao to set.
158: */
159: public void setOrganizationDao(OrganizationDao organizationDao) {
160: this.organizationDao = organizationDao;
161: }
162:
163: }
|