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.financial.service.impl;
017:
018: import org.kuali.core.bo.user.UniversalUser;
019: import org.kuali.core.exceptions.UserNotFoundException;
020: import org.kuali.core.service.impl.KualiModuleUserServiceBaseImpl;
021: import org.kuali.module.chart.bo.ChartUser;
022: import org.kuali.module.financial.bo.FinancialUser;
023: import org.kuali.module.financial.service.FinancialUserService;
024: import org.springframework.transaction.annotation.Transactional;
025:
026: /**
027: *
028: * This is the default implementation of the FinancialUserService interface.
029: */
030: @Transactional
031: public class FinancialUserServiceImpl extends
032: KualiModuleUserServiceBaseImpl<FinancialUser> implements
033: FinancialUserService {
034:
035: /**
036: * This method creates a FinancialUser from the UniversalUser provided.
037: *
038: * @param universalUser The user to be used for creating the FinancialUser returned.
039: * @return A new instance of a FinancialUser created from the UniversalUser passed in.
040: *
041: * @see org.kuali.core.service.KualiModuleUserService#getModuleUser(org.kuali.core.bo.user.UniversalUser)
042: */
043: public FinancialUser getModuleUser(UniversalUser universalUser)
044: throws UserNotFoundException {
045: FinancialUser financialUser = new FinancialUser(universalUser);
046: return financialUser;
047: }
048:
049: /**
050: * This method retrieves a criteria object populated with the necessary search parameters needed to determine
051: * if a given user is active.
052: *
053: * @return An criteria object populated with the attributes necessary to determine if a user is active or not.
054: *
055: * @see org.kuali.core.service.impl.KualiModuleUserServiceBaseImpl#getUserActiveCriteria()
056: */
057: public Object getUserActiveCriteria() {
058: return kualiModuleUserDao
059: .getActiveUserQueryCriteria(ChartUser.MODULE_ID);
060: }
061:
062: /**
063: * Returns the chart code from the ChartUser as the default chart code.
064: *
065: * @param user The user object used to retrieve the associated chart code.
066: * @return The chart code associated with the user provided or empty string if no values can be found.
067: *
068: * @see org.kuali.module.financial.service.FinancialUserService#getDefaultChartOfAccountsCode(org.kuali.module.financial.bo.FinancialUser)
069: */
070: public String getDefaultChartOfAccountsCode(FinancialUser user) {
071: if (user.getUniversalUser() == null) {
072: return "";
073: }
074: ChartUser chartUser = (ChartUser) user.getUniversalUser()
075: .getModuleUser(ChartUser.MODULE_ID);
076: if (chartUser == null) {
077: return "";
078: }
079: return chartUser.getChartOfAccountsCode();
080: }
081:
082: /**
083: * Returns the primary department ID from the ChartUser table as the organization code.
084: *
085: * @param user The user object used to retrieve the associated org code.
086: * @return The org code associated with the user provided or empty string if no values can be found.
087: *
088: * @see org.kuali.module.financial.service.FinancialUserService#getDefaultOrganizationCode(org.kuali.module.financial.bo.FinancialUser)
089: */
090: public String getDefaultOrganizationCode(FinancialUser user) {
091: if (user.getUniversalUser() == null) {
092: return "";
093: }
094: ChartUser chartUser = (ChartUser) user.getUniversalUser()
095: .getModuleUser(ChartUser.MODULE_ID);
096: if (chartUser == null) {
097: return "";
098: }
099: return chartUser.getOrganizationCode();
100: }
101:
102: }
|