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.gl.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.gl.GeneralLedgerConstants;
026    import org.kuali.kfs.gl.businessobject.AccountBalanceByObject;
027    import org.kuali.kfs.gl.businessobject.lookup.BusinessObjectFieldConverter;
028    import org.kuali.kfs.sys.KFSConstants;
029    import org.kuali.kfs.sys.KFSPropertyConstants;
030    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
031    
032    /**
033     * This class is used to generate the URL for the user-defined attributes for the account balace by object screen. It is entended
034     * the AbstractGeneralLedgerInquirableImpl class, so it covers both the default implementation and customized implemetnation.
035     */
036    public class AccountBalanceByObjectInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
037        @SuppressWarnings("unused")
038        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByObjectInquirableImpl.class);
039    
040        /**
041         * Builds the keys for this inquiry.
042         * @return a List of Strings, holding the keys of this inquiry
043         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
044         */
045        protected List buildUserDefinedAttributeKeyList() {
046            List keys = new ArrayList();
047    
048            keys.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
049            keys.add(KFSPropertyConstants.ACCOUNT_NUMBER);
050            keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
051            keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
052            keys.add(KFSPropertyConstants.OBJECT_CODE);
053            keys.add(KFSPropertyConstants.SUB_OBJECT_CODE);
054            keys.add(Constant.COST_SHARE_OPTION);
055            keys.add(Constant.CONSOLIDATION_OPTION);
056    
057            return keys;
058        }
059    
060        /**
061         * The addition of a couple attributes to the lookup - object code, object level, and link button
062         * @return a Map of user defined attributes
063         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
064         */
065        protected Map getUserDefinedAttributeMap() {
066            Map userDefinedAttributeMap = new HashMap();
067            userDefinedAttributeMap.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, "");
068            userDefinedAttributeMap.put(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION, "");
069            userDefinedAttributeMap.put(GeneralLedgerConstants.BalanceInquiryDrillDowns.OBJECT_LEVEL_CODE, "");
070            return userDefinedAttributeMap;
071        }
072    
073        /**
074         * Changes the name of attributes on the fly...in this case, turns the link button to display its name as glpe
075         * @param attributeName the attribute to rename
076         * @return a String with the new attribute name
077         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
078         */
079        protected String getAttributeName(String attributeName) {
080            if (attributeName.equals(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION)) {
081                attributeName = KFSPropertyConstants.GENERAL_LEDGER_PENDING_ENTRY;
082            }
083            return attributeName;
084        }
085    
086        /**
087         * If the key name sent in represents an "exclusive field", returns "" as the key value
088         * @param keyName the name of the key that may be changed
089         * @param keyValue the value of the key that may be changed
090         * @return an Object with the perhaps modified value for the key
091         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
092         */
093        protected Object getKeyValue(String keyName, Object keyValue) {
094            if (isExclusiveField(keyName, keyValue)) {
095                keyValue = "";
096            }
097            return keyValue;
098        }
099    
100        /**
101         * Justs returns the key name given
102         * @param keyName a key name
103         * @return the key name given
104         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
105         */
106        protected String getKeyName(String keyName) {
107            keyName = BusinessObjectFieldConverter.convertToTransactionPropertyName(keyName);
108            return keyName;
109        }
110    
111        /**
112         * Return a Spring bean for the lookup
113         * @return the name of the Spring bean of the lookup
114         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
115         */
116        protected String getLookupableImplAttributeName() {
117            return Constant.GL_LOOKUPABLE_PENDING_ENTRY;
118        }
119    
120        /**
121         * Return the page name of this lookup
122         * @return the page name for all GL lookups
123         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
124         */
125        protected String getBaseUrl() {
126            return KFSConstants.GL_MODIFIED_INQUIRY_ACTION;
127        }
128    
129        /**
130         * Retrieves the business class to use as the basis of an inquiry for the given attribute
131         * @param attributeName the name to build the inquiry link to
132         * @return the Class of the business object that should be inquired on
133         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
134         */
135        protected Class getInquiryBusinessObjectClass(String attributeName) {
136            if (KFSPropertyConstants.GENERAL_LEDGER_PENDING_ENTRY.equals(attributeName)) {
137                return GeneralLedgerPendingEntry.class;
138            }
139            return AccountBalanceByObject.class;
140        }
141    
142        /**
143         * Addes the lookup impl attribute to the parameters
144         * @param parameter the parameters used in the lookup
145         * @param attributeName the attribute name that an inquiry URL is being built for
146         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
147         */
148        protected void addMoreParameters(Properties parameter, String attributeName) {
149            parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
150        }
151    }