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.financial.service.impl;
017:
018: import org.kuali.kfs.service.KualiCodeService;
019: import org.kuali.module.financial.bo.CashDetailTypeCode;
020: import org.kuali.module.financial.service.CashDetailTypeCodeService;
021: import org.springframework.transaction.annotation.Transactional;
022:
023: /**
024: * This is the default implementation for the CashDetailTypeCodeService interface. This implementation used the KualiCodeService,
025: * which in turn uses the KualiCodeDao for retrieving values from the database.
026: */
027: @Transactional
028: public class CashDetailTypeCodeServiceImpl implements
029: CashDetailTypeCodeService {
030: private KualiCodeService kualiCodeService;
031:
032: // KFSConstants for doing the actual lookups
033: public final static String CASH_RECEIPT_CHECK = "CRCHK";
034: public final static String CASH_RECEIPT_COIN = "CRCOIN";
035:
036: /**
037: * Constructs a CashDetailTypeCodeServiceImpl instance.
038: */
039: public CashDetailTypeCodeServiceImpl() {
040: }
041:
042: /**
043: * Gets the kualiCodeService attribute.
044: *
045: * @return Returns the kualiCodeService.
046: */
047: public KualiCodeService getKualiCodeService() {
048: return kualiCodeService;
049: }
050:
051: /**
052: * Sets the kualiCodeService attribute value.
053: *
054: * @param kualiCodeService The kualiCodeService to set.
055: */
056: public void setKualiCodeService(KualiCodeService kualiCodeService) {
057: this .kualiCodeService = kualiCodeService;
058: }
059:
060: /**
061: * Gets the associated check type code for a CashReceipt.
062: *
063: * @return Returns the CashReceipt check type code.
064: * @see org.kuali.core.service.CashDetailTypeCode#getCashReceiptCheckTypeCode()
065: */
066: public CashDetailTypeCode getCashReceiptCheckTypeCode() {
067: return getCashDetailTypeCodeByCode(CASH_RECEIPT_CHECK);
068: }
069:
070: /**
071: * Gets the associated coin type code for a CashReceipt.
072: *
073: * @return Returns the CashReceipt coin type code.
074: * @see org.kuali.core.service.CashDetailTypeCode#getCashReceiptCoinTypeCode()
075: */
076: public CashDetailTypeCode getCashReceiptCoinTypeCode() {
077: return getCashDetailTypeCodeByCode(CASH_RECEIPT_CHECK);
078: }
079:
080: /**
081: * Retrieves a populated instance corresponding to the code passed into this method. This is retrieved via the KualiCodeService
082: * and in turn from the database.
083: *
084: * TODO - uncomment the commented out line and remove the others when the table is in place
085: *
086: * @param cashDetailTypeCode The identifier used to retrieve the appropriate type code object.
087: * @return A CashDetailTypeCode instance based on the code provided.
088: *
089: * @see #CASH_RECEIPT_CHECK
090: * @see #CASH_RECEIPT_COIN
091: */
092: private CashDetailTypeCode getCashDetailTypeCodeByCode(
093: String cashDetailTypeCode) {
094: // return (CashDetailTypeCode) kualiCodeService.getByCode(CashDetailTypeCode.class, cashDetailTypeCode);
095: return getDummyInstance(cashDetailTypeCode);
096: }
097:
098: /**
099: * This method is a temporary helper method. This should be removed when the lookup table for CashDetailTypeCode business
100: * objects is put in place. Then we'll be retrieving the stuff from the database.
101: *
102: * TODO - remove this method after the table is in place; this is a temp helper method
103: *
104: * @param cashDetailTypeCodeCode The code to populate the dummy instance with.
105: * @return A CashDetailTypeCode instance based on the value provided.
106: */
107: private CashDetailTypeCode getDummyInstance(
108: String cashDetailTypeCodeCode) {
109: CashDetailTypeCode cashDetailTypeCode = new CashDetailTypeCode();
110: cashDetailTypeCode.setCode(cashDetailTypeCodeCode);
111: return cashDetailTypeCode;
112: }
113: }
|