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.AccountBalanceByLevel;
027    import org.kuali.kfs.sys.KFSConstants;
028    import org.kuali.kfs.sys.KFSPropertyConstants;
029    import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
030    import org.kuali.rice.kns.service.LookupService;
031    
032    /**
033     * This class is used to generate the URL for the user-defined attributes for the account balace by consolidation screen. It is
034     * entended the KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation.
035     */
036    public class AccountBalanceByConsolidationInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
037        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByConsolidationInquirableImpl.class);
038    
039        private BusinessObjectDictionaryService dataDictionary;
040        private LookupService lookupService;
041        private Class businessObjectClass;
042    
043        /**
044         * Builds a list of attributes for finding the values for this inquiry.
045         * 
046         * @return a List of attribute keys to inquire on
047         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
048         */
049        protected List buildUserDefinedAttributeKeyList() {
050            List keys = new ArrayList();
051    
052            keys.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
053            keys.add(KFSPropertyConstants.ACCOUNT_NUMBER);
054            keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
055            keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
056            keys.add("financialObject.financialObjectLevel.financialConsolidationObject.finConsolidationObjectCode");
057            keys.add(Constant.COST_SHARE_OPTION);
058            keys.add(Constant.CONSOLIDATION_OPTION);
059            keys.add(Constant.PENDING_ENTRY_OPTION);
060    
061            return keys;
062        }
063    
064        /**
065         * Generates an attribute map of fields created simply for this inquiry
066         * 
067         * @return a Map with a link button attribute in it
068         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
069         */
070        protected Map getUserDefinedAttributeMap() {
071            Map userDefinedAttributeMap = new HashMap();
072            // userDefinedAttributeMap.put("financialObject.financialObjectLevel.financialConsolidationObject.financialConsolidationObjectCode",
073            // "");
074            userDefinedAttributeMap.put(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION, "");
075            return userDefinedAttributeMap;
076        }
077    
078        /**
079         * Converts attribute names for the inquiry screen
080         * 
081         * @return the converted name of the attribute
082         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
083         */
084        protected String getAttributeName(String attributeName) {
085            // if (attributeName.equals("dummyBusinessObject.linkButtonOption")) {
086            // attributeName = "financialObject.financialObjectLevel";
087            // }
088            return attributeName;
089        }
090    
091        /**
092         * Overrides the key value with a blank string if it's an exclusive value
093         * 
094         * @param keyName the keyName of the key to check
095         * @param keyValue the value of the key to check
096         * @return a new value
097         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
098         */
099        protected Object getKeyValue(String keyName, Object keyValue) {
100            if (isExclusiveField(keyName, keyValue)) {
101                keyValue = "";
102            }
103            return keyValue;
104        }
105    
106        /**
107         * Given a key name, returns the key name; this implementation just passes back what it gets
108         * 
109         * @return the key name passed in
110         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
111         */
112        protected String getKeyName(String keyName) {
113            return keyName;
114        }
115    
116        /**
117         * The name of this inquiry
118         * 
119         * @return a String with this inquiry's name
120         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
121         */
122        protected String getLookupableImplAttributeName() {
123            return Constant.GL_LOOKUPABLE_ACCOUNT_BALANCE_BY_LEVEL;
124        }
125    
126        /**
127         * The base url that inquires of this type need to be sent to
128         * 
129         * @return the base url
130         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
131         */
132        protected String getBaseUrl() {
133            return KFSConstants.GL_MODIFIED_INQUIRY_ACTION;
134        }
135    
136        /**
137         * The business object class this inquiry should be returning for a given attribute - in this case, AccountBalanceByLevel for the LINK_BUTTON_OPTION
138         * 
139         * @param attributeName the attribute to return a class for
140         * @return a class for the attribute
141         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
142         */
143        protected Class getInquiryBusinessObjectClass(String attributeName) {
144            Class c = null;
145            if (GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION.equals(attributeName)) {
146                c = AccountBalanceByLevel.class;
147            }
148            return c;
149        }
150    
151        /**
152         * For a given attribute, lets this inquiry add more parameters
153         * @param parameter the set of parameters for the inquiry
154         * @param attributeName the attributeName parameters are being set for
155         * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
156         */
157        protected void addMoreParameters(Properties parameter, String attributeName) {
158            parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
159        }
160    }