1 /* 2 * The Kuali Financial System, a comprehensive financial management system for higher education. 3 * 4 * Copyright 2005-2014 The Kuali Foundation 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 package org.kuali.kfs.gl.businessobject.inquiry; 20 21 import java.util.ArrayList; 22 import java.util.HashMap; 23 import java.util.List; 24 import java.util.Map; 25 import java.util.Properties; 26 27 import org.kuali.kfs.gl.Constant; 28 import org.kuali.kfs.gl.GeneralLedgerConstants; 29 import org.kuali.kfs.gl.businessobject.AccountBalanceByLevel; 30 import org.kuali.kfs.sys.KFSConstants; 31 import org.kuali.kfs.sys.KFSPropertyConstants; 32 import org.kuali.rice.kns.service.BusinessObjectDictionaryService; 33 import org.kuali.rice.krad.service.LookupService; 34 35 /** 36 * This class is used to generate the URL for the user-defined attributes for the account balace by consolidation screen. It is 37 * entended the KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation. 38 */ 39 public class AccountBalanceByConsolidationInquirableImpl extends AbstractGeneralLedgerInquirableImpl { 40 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByConsolidationInquirableImpl.class); 41 42 private BusinessObjectDictionaryService dataDictionary; 43 private LookupService lookupService; 44 private Class businessObjectClass; 45 46 /** 47 * Builds a list of attributes for finding the values for this inquiry. 48 * 49 * @return a List of attribute keys to inquire on 50 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList() 51 */ 52 protected List buildUserDefinedAttributeKeyList() { 53 List keys = new ArrayList(); 54 55 keys.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR); 56 keys.add(KFSPropertyConstants.ACCOUNT_NUMBER); 57 keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 58 keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); 59 keys.add("financialObject.financialObjectLevel.financialConsolidationObject.finConsolidationObjectCode"); 60 keys.add(Constant.COST_SHARE_OPTION); 61 keys.add(Constant.CONSOLIDATION_OPTION); 62 keys.add(Constant.PENDING_ENTRY_OPTION); 63 64 return keys; 65 } 66 67 /** 68 * Generates an attribute map of fields created simply for this inquiry 69 * 70 * @return a Map with a link button attribute in it 71 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap() 72 */ 73 protected Map getUserDefinedAttributeMap() { 74 Map userDefinedAttributeMap = new HashMap(); 75 // userDefinedAttributeMap.put("financialObject.financialObjectLevel.financialConsolidationObject.financialConsolidationObjectCode", 76 // ""); 77 userDefinedAttributeMap.put(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION, ""); 78 return userDefinedAttributeMap; 79 } 80 81 /** 82 * Converts attribute names for the inquiry screen 83 * 84 * @return the converted name of the attribute 85 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String) 86 */ 87 protected String getAttributeName(String attributeName) { 88 // if (attributeName.equals("dummyBusinessObject.linkButtonOption")) { 89 // attributeName = "financialObject.financialObjectLevel"; 90 // } 91 return attributeName; 92 } 93 94 /** 95 * Overrides the key value with a blank string if it's an exclusive value 96 * 97 * @param keyName the keyName of the key to check 98 * @param keyValue the value of the key to check 99 * @return a new value 100 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object) 101 */ 102 protected Object getKeyValue(String keyName, Object keyValue) { 103 if (isExclusiveField(keyName, keyValue)) { 104 keyValue = ""; 105 } 106 return keyValue; 107 } 108 109 /** 110 * Given a key name, returns the key name; this implementation just passes back what it gets 111 * 112 * @return the key name passed in 113 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String) 114 */ 115 protected String getKeyName(String keyName) { 116 return keyName; 117 } 118 119 /** 120 * The name of this inquiry 121 * 122 * @return a String with this inquiry's name 123 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName() 124 */ 125 protected String getLookupableImplAttributeName() { 126 return Constant.GL_LOOKUPABLE_ACCOUNT_BALANCE_BY_LEVEL; 127 } 128 129 /** 130 * The base url that inquires of this type need to be sent to 131 * 132 * @return the base url 133 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl() 134 */ 135 protected String getBaseUrl() { 136 return KFSConstants.GL_MODIFIED_INQUIRY_ACTION; 137 } 138 139 /** 140 * The business object class this inquiry should be returning for a given attribute - in this case, AccountBalanceByLevel for the LINK_BUTTON_OPTION 141 * 142 * @param attributeName the attribute to return a class for 143 * @return a class for the attribute 144 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String) 145 */ 146 protected Class getInquiryBusinessObjectClass(String attributeName) { 147 Class c = null; 148 if (GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION.equals(attributeName)) { 149 c = AccountBalanceByLevel.class; 150 } 151 return c; 152 } 153 154 /** 155 * For a given attribute, lets this inquiry add more parameters 156 * @param parameter the set of parameters for the inquiry 157 * @param attributeName the attributeName parameters are being set for 158 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String) 159 */ 160 protected void addMoreParameters(Properties parameter, String attributeName) { 161 parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName()); 162 } 163 }