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