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.kfs.bo.Options;
029: import org.kuali.kfs.context.SpringContext;
030: import org.kuali.kfs.service.OptionsService;
031: import org.kuali.module.gl.bo.Balance;
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 available account balace screen. It is entended the
036: * AbstractGLInquirableImpl class, so it covers both the default implementation and customized implemetnation.
037: */
038: public class AccountBalanceInquirableImpl extends
039: AbstractGLInquirableImpl {
040: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
041: .getLogger(AccountBalanceInquirableImpl.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.add(KFSPropertyConstants.OBJECT_CODE);
060: keys.add(KFSPropertyConstants.SUB_OBJECT_CODE);
061: keys.add(Constant.CONSOLIDATION_OPTION);
062: keys.add(Constant.PENDING_ENTRY_OPTION);
063:
064: return keys;
065: }
066:
067: /**
068: * The addition of user attributes - current budget, actual budget, and encumbrance balance
069: * @return a Map of user defined attributes
070: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getUserDefinedAttributeMap()
071: */
072: protected Map getUserDefinedAttributeMap() {
073: Map userDefinedAttributeMap = new HashMap();
074:
075: OptionsService os = SpringContext.getBean(OptionsService.class);
076: Options o = os.getCurrentYearOptions();
077:
078: userDefinedAttributeMap
079: .put(
080: KFSPropertyConstants.CURRENT_BUDGET_LINE_BALANCE_AMOUNT,
081: Constant.BALANCE_TYPE_CB);
082: userDefinedAttributeMap
083: .put(
084: KFSPropertyConstants.ACCOUNT_LINE_ACTUALS_BALANCE_AMOUNT,
085: o.getActualFinancialBalanceTypeCd());
086: userDefinedAttributeMap
087: .put(
088: KFSPropertyConstants.ACCOUNT_LINE_ENCUMBRANCE_BALANCE_AMOUNT,
089: KFSConstants.AGGREGATE_ENCUMBRANCE_BALANCE_TYPE_CODE);
090:
091: return userDefinedAttributeMap;
092: }
093:
094: /**
095: * Changes the name of attributes on the fly...in this case, doesn't do anything
096: * @param attributeName the attribute to rename
097: * @return a String with the new attribute name
098: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getAttributeName(java.lang.String)
099: */
100: protected String getAttributeName(String attributeName) {
101: return attributeName;
102: }
103:
104: /**
105: * If the key name sent in represents an "exclusive field", returns "" as the key value
106: * @param keyName the name of the key that may be changed
107: * @param keyValue the value of the key that may be changed
108: * @return an Object with the perhaps modified value for the key
109: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
110: */
111: protected Object getKeyValue(String keyName, Object keyValue) {
112: if (isExclusiveField(keyName, keyValue)) {
113: keyValue = "";
114: }
115: return keyValue;
116: }
117:
118: /**
119: * Justs returns the key name given
120: * @param keyName a key name
121: * @return the key name given
122: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getKeyName(java.lang.String)
123: */
124: protected String getKeyName(String keyName) {
125: return keyName;
126: }
127:
128: /**
129: * Return a Spring bean for the drill up lookup, which is the balance lookup
130: * @return the name of the Spring bean of the lookup
131: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getLookupableImplAttributeName()
132: */
133: protected String getLookupableImplAttributeName() {
134: return Constant.GL_LOOKUPABLE_BALANCE;
135: }
136:
137: /**
138: * Return the page name of this lookup
139: * @return the page name for inquiry options
140: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getBaseUrl()
141: */
142: protected String getBaseUrl() {
143: return KFSConstants.GL_BALANCE_INQUIRY_ACTION;
144: }
145:
146: /**
147: * Retrieves the business class to use as the basis of an inquiry for the given attribute; in this case, it's always Balance
148: * @param attributeName the name to build the inquiry link to
149: * @return the Class of the business object that should be inquired on
150: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getInquiryBusinessObjectClass(String)
151: */
152: protected Class getInquiryBusinessObjectClass(String attributeName) {
153: return Balance.class;
154: }
155:
156: /**
157: * Addes the lookup impl and balance type attributes to the parameters
158: * @param parameter the parameters used in the lookup
159: * @param attributeName the attribute name that an inquiry URL is being built for
160: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
161: */
162: protected void addMoreParameters(Properties parameter,
163: String attributeName) {
164: parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME,
165: getLookupableImplAttributeName());
166: parameter.put(Constant.AMOUNT_VIEW_OPTION, Constant.MONTHLY);
167:
168: String balanceTypeCode = (String) getUserDefinedAttributeMap()
169: .get(getAttributeName(attributeName));
170: parameter.put(KFSConstants.BALANCE_TYPE_PROPERTY_NAME,
171: balanceTypeCode);
172: }
173: }
|