001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.module.ld.businessobject.inquiry;
017    
018    import java.util.ArrayList;
019    import java.util.HashMap;
020    import java.util.List;
021    import java.util.Map;
022    import java.util.Properties;
023    
024    import org.kuali.kfs.gl.Constant;
025    import org.kuali.kfs.module.ld.businessobject.LedgerEntry;
026    import org.kuali.kfs.sys.KFSConstants;
027    import org.kuali.kfs.sys.KFSPropertyConstants;
028    
029    /**
030     * Service implementation of LedgerBalanceInquirable. This class is used to generate the URL for the user-defined attributes for the
031     * Ledger Balance screen. It is entended the KualiInquirableImpl class, so it covers both the default implementation and customized
032     * implemetnation.
033     */
034    public class LedgerBalanceInquirableImpl extends AbstractLaborInquirableImpl {
035        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LedgerBalanceInquirableImpl.class);
036    
037        /**
038         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
039         */
040        protected List buildUserDefinedAttributeKeyList() {
041            List keys = new ArrayList();
042    
043            keys.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
044            keys.add(KFSPropertyConstants.ACCOUNT_NUMBER);
045            keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
046            keys.add(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
047            keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
048            keys.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
049            keys.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
050            keys.add(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
051            keys.add(KFSPropertyConstants.EMPLID);
052            keys.add(KFSPropertyConstants.POSITION_NUMBER);
053            keys.add(Constant.PENDING_ENTRY_OPTION);
054    
055            return keys;
056        }
057    
058        /**
059         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
060         */
061        protected Map getUserDefinedAttributeMap() {
062            Map userDefinedAttributeMap = new HashMap();
063    
064            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH1_AMOUNT, KFSConstants.MONTH1);
065            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH2_AMOUNT, KFSConstants.MONTH2);
066            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH3_AMOUNT, KFSConstants.MONTH3);
067    
068            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH4_AMOUNT, KFSConstants.MONTH4);
069            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH5_AMOUNT, KFSConstants.MONTH5);
070            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH6_AMOUNT, KFSConstants.MONTH6);
071    
072            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH7_AMOUNT, KFSConstants.MONTH7);
073            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH8_AMOUNT, KFSConstants.MONTH8);
074            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH9_AMOUNT, KFSConstants.MONTH9);
075    
076            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH10_AMOUNT, KFSConstants.MONTH10);
077            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH11_AMOUNT, KFSConstants.MONTH11);
078            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH12_AMOUNT, KFSConstants.MONTH12);
079            userDefinedAttributeMap.put(KFSPropertyConstants.MONTH13_AMOUNT, KFSConstants.MONTH13);
080    
081            userDefinedAttributeMap.put(KFSPropertyConstants.FINANCIAL_BEGINNING_BALANCE_LINE_AMOUNT, KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
082            userDefinedAttributeMap.put(KFSPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT, KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE);
083    
084            return userDefinedAttributeMap;
085        }
086    
087        /**
088         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
089         */
090        protected String getAttributeName(String attributeName) {
091            return attributeName;
092        }
093    
094        /**
095         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
096         */
097        protected Object getKeyValue(String keyName, Object keyValue) {
098            if (isExclusiveField(keyName, keyValue)) {
099                keyValue = Constant.EMPTY_STRING;
100            }
101            return keyValue;
102        }
103    
104        /**
105         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
106         */
107        protected String getKeyName(String keyName) {
108            return keyName;
109        }
110    
111        /**
112         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
113         */
114        protected String getLookupableImplAttributeName() {
115            return null;
116        }
117    
118        /**
119         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
120         */
121        protected String getBaseUrl() {
122            return KFSConstants.GL_MODIFIED_INQUIRY_ACTION;
123        }
124    
125        /**
126         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
127         */
128        protected Class getInquiryBusinessObjectClass(String attributeName) {
129            return LedgerEntry.class;
130        }
131    
132        /**
133         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
134         */
135        protected void addMoreParameters(Properties parameter, String attributeName) {
136            String periodCode = (String) getUserDefinedAttributeMap().get(attributeName);
137            parameter.put(KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME, periodCode);
138        }
139    }