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