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.bo.Entry;
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 GL balace screen. It is entended the
034: * KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation.
035: */
036: public class BalanceInquirableImpl extends AbstractGLInquirableImpl {
037: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
038: .getLogger(BalanceInquirableImpl.class);
039:
040: private BusinessObjectDictionaryService dataDictionary;
041: private LookupService lookupService;
042: private Class businessObjectClass;
043:
044: /**
045: * Builds the keys for this inquiry.
046: * @return a List of Strings, holding the keys of this inquiry
047: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#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.BALANCE_TYPE_CODE);
056: keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
057: keys.add(KFSPropertyConstants.OBJECT_CODE);
058: keys.add(KFSPropertyConstants.SUB_OBJECT_CODE);
059: keys.add(KFSPropertyConstants.OBJECT_TYPE_CODE);
060: keys.add(Constant.PENDING_ENTRY_OPTION);
061:
062: return keys;
063: }
064:
065: /**
066: * The addition of all the month amounts, plus beginning balance and c&g balance as attributes
067: * @return a Map of user defined attributes
068: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getUserDefinedAttributeMap()
069: */
070: protected Map getUserDefinedAttributeMap() {
071: Map userDefinedAttributeMap = new HashMap();
072:
073: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH1_AMOUNT,
074: KFSConstants.MONTH1);
075: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH2_AMOUNT,
076: KFSConstants.MONTH2);
077: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH3_AMOUNT,
078: KFSConstants.MONTH3);
079:
080: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH4_AMOUNT,
081: KFSConstants.MONTH4);
082: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH5_AMOUNT,
083: KFSConstants.MONTH5);
084: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH6_AMOUNT,
085: KFSConstants.MONTH6);
086:
087: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH7_AMOUNT,
088: KFSConstants.MONTH7);
089: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH8_AMOUNT,
090: KFSConstants.MONTH8);
091: userDefinedAttributeMap.put(KFSPropertyConstants.MONTH9_AMOUNT,
092: KFSConstants.MONTH9);
093:
094: userDefinedAttributeMap.put(
095: KFSPropertyConstants.MONTH10_AMOUNT,
096: KFSConstants.MONTH10);
097: userDefinedAttributeMap.put(
098: KFSPropertyConstants.MONTH11_AMOUNT,
099: KFSConstants.MONTH11);
100: userDefinedAttributeMap.put(
101: KFSPropertyConstants.MONTH12_AMOUNT,
102: KFSConstants.MONTH12);
103: userDefinedAttributeMap.put(
104: KFSPropertyConstants.MONTH13_AMOUNT,
105: KFSConstants.MONTH13);
106:
107: userDefinedAttributeMap.put(
108: KFSPropertyConstants.BEGINNING_BALANCE_LINE_AMOUNT,
109: KFSConstants.PERIOD_CODE_BEGINNING_BALANCE);
110: userDefinedAttributeMap
111: .put(
112: KFSPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT,
113: KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE);
114:
115: return userDefinedAttributeMap;
116: }
117:
118: /**
119: * Changes the name of attributes on the fly...in this case, this just always returns the attribute name it's handed
120: * @param attributeName the attribute to rename
121: * @return a String with the new attribute name
122: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getAttributeName(java.lang.String)
123: */
124: protected String getAttributeName(String attributeName) {
125: return attributeName;
126: }
127:
128: /**
129: * If the key name sent in represents an "exclusive field", returns "" as the key value
130: * @param keyName the name of the key that may be changed
131: * @param keyValue the value of the key that may be changed
132: * @return an Object with the perhaps modified value for the key
133: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
134: */
135: protected Object getKeyValue(String keyName, Object keyValue) {
136: if (isExclusiveField(keyName, keyValue)) {
137: keyValue = Constant.EMPTY_STRING;
138: }
139: return keyValue;
140: }
141:
142: /**
143: * Justs returns the key name given
144: * @param keyName a key name
145: * @return the key name given
146: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getKeyName(java.lang.String)
147: */
148: protected String getKeyName(String keyName) {
149: keyName = BusinessObjectFieldConverter
150: .convertToTransactionPropertyName(keyName);
151: return keyName;
152: }
153:
154: /**
155: * Return a Spring bean for the lookup
156: * @return the name of the Spring bean of the lookup
157: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getLookupableImplAttributeName()
158: */
159: protected String getLookupableImplAttributeName() {
160: return Constant.GL_LOOKUPABLE_ENTRY;
161: }
162:
163: /**
164: * Return the page name of this lookup
165: * @return the page name for all GL lookups
166: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getBaseUrl()
167: */
168: protected String getBaseUrl() {
169: return KFSConstants.GL_MODIFIED_INQUIRY_ACTION;
170: }
171:
172: /**
173: * Retrieves the business class of the next class type to drill up...since balance summarizes entry, it's entry
174: * @param attributeName the name to build the inquiry link to
175: * @return the Class of the business object that should be inquired on
176: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getInquiryBusinessObjectClass(String)
177: */
178: protected Class getInquiryBusinessObjectClass(String attributeName) {
179: return Entry.class;
180: }
181:
182: /**
183: * Addes the lookup impl and period code attributes to the parameters
184: * @param parameter the parameters used in the lookup
185: * @param attributeName the attribute name that an inquiry URL is being built for
186: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
187: */
188: protected void addMoreParameters(Properties parameter,
189: String attributeName) {
190: parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME,
191: getLookupableImplAttributeName());
192:
193: String periodCode = (String) getUserDefinedAttributeMap().get(
194: attributeName);
195: parameter
196: .put(
197: KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME,
198: periodCode);
199: }
200: }
|