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.AccountBalanceByLevel;
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 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
037: AbstractGLInquirableImpl {
038: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
039: .getLogger(AccountBalanceByConsolidationInquirableImpl.class);
040:
041: private BusinessObjectDictionaryService dataDictionary;
042: private LookupService lookupService;
043: private Class businessObjectClass;
044:
045: /**
046: * Builds a list of attributes for finding the values for this inquiry.
047: *
048: * @return a List of attribute keys to inquire on
049: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#buildUserDefinedAttributeKeyList()
050: */
051: protected List buildUserDefinedAttributeKeyList() {
052: List keys = new ArrayList();
053:
054: keys.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
055: keys.add(KFSPropertyConstants.ACCOUNT_NUMBER);
056: keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
057: keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
058: keys
059: .add("financialObject.financialObjectLevel.financialConsolidationObject.finConsolidationObjectCode");
060: keys.add(Constant.COST_SHARE_OPTION);
061: keys.add(Constant.CONSOLIDATION_OPTION);
062: keys.add(Constant.PENDING_ENTRY_OPTION);
063:
064: return keys;
065: }
066:
067: /**
068: * Generates an attribute map of fields created simply for this inquiry
069: *
070: * @return a Map with a link button attribute in it
071: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getUserDefinedAttributeMap()
072: */
073: protected Map getUserDefinedAttributeMap() {
074: Map userDefinedAttributeMap = new HashMap();
075: // userDefinedAttributeMap.put("financialObject.financialObjectLevel.financialConsolidationObject.financialConsolidationObjectCode",
076: // "");
077: userDefinedAttributeMap.put(
078: GLConstants.DummyBusinessObject.LINK_BUTTON_OPTION, "");
079: return userDefinedAttributeMap;
080: }
081:
082: /**
083: * Converts attribute names for the inquiry screen
084: *
085: * @return the converted name of the attribute
086: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getAttributeName(java.lang.String)
087: */
088: protected String getAttributeName(String attributeName) {
089: // if (attributeName.equals("dummyBusinessObject.linkButtonOption")) {
090: // attributeName = "financialObject.financialObjectLevel";
091: // }
092: return attributeName;
093: }
094:
095: /**
096: * Overrides the key value with a blank string if it's an exclusive value
097: *
098: * @param keyName the keyName of the key to check
099: * @param keyValue the value of the key to check
100: * @return a new value
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: * Given a key name, returns the key name; this implementation just passes back what it gets
112: *
113: * @return the key name passed in
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: * The name of this inquiry
122: *
123: * @return a String with this inquiry's name
124: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getLookupableImplAttributeName()
125: */
126: protected String getLookupableImplAttributeName() {
127: return Constant.GL_LOOKUPABLE_ACCOUNT_BALANCE_BY_LEVEL;
128: }
129:
130: /**
131: * The base url that inquires of this type need to be sent to
132: *
133: * @return the base url
134: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getBaseUrl()
135: */
136: protected String getBaseUrl() {
137: return KFSConstants.GL_MODIFIED_INQUIRY_ACTION;
138: }
139:
140: /**
141: * The business object class this inquiry should be returning for a given attribute - in this case, AccountBalanceByLevel for the LINK_BUTTON_OPTION
142: *
143: * @param attributeName the attribute to return a class for
144: * @return a class for the attribute
145: * @see org.kuali.module.gl.web.inquirable.AbstractGLInquirableImpl#getInquiryBusinessObjectClass(String)
146: */
147: protected Class getInquiryBusinessObjectClass(String attributeName) {
148: Class c = null;
149: if (GLConstants.DummyBusinessObject.LINK_BUTTON_OPTION
150: .equals(attributeName)) {
151: c = AccountBalanceByLevel.class;
152: }
153: return c;
154: }
155:
156: /**
157: * For a given attribute, lets this inquiry add more parameters
158: * @param parameter the set of parameters for the inquiry
159: * @param attributeName the attributeName parameters are being set 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: }
167: }
|