001/* 002 * The Kuali Financial System, a comprehensive financial management system for higher education. 003 * 004 * Copyright 2005-2014 The Kuali Foundation 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU Affero General Public License as 008 * published by the Free Software Foundation, either version 3 of the 009 * License, or (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU Affero General Public License for more details. 015 * 016 * You should have received a copy of the GNU Affero General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.kuali.kfs.gl.businessobject.inquiry; 020 021import java.util.ArrayList; 022import java.util.HashMap; 023import java.util.List; 024import java.util.Map; 025import java.util.Properties; 026 027import org.kuali.kfs.gl.Constant; 028import org.kuali.kfs.gl.businessobject.Entry; 029import org.kuali.kfs.gl.businessobject.lookup.BusinessObjectFieldConverter; 030import org.kuali.kfs.sys.KFSConstants; 031import org.kuali.kfs.sys.KFSPropertyConstants; 032import org.kuali.rice.kns.service.BusinessObjectDictionaryService; 033import org.kuali.rice.krad.service.LookupService; 034 035/** 036 * This class is used to generate the URL for the user-defined attributes for the GL balace screen. It is entended the 037 * KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation. 038 */ 039public class BalanceInquirableImpl extends AbstractGeneralLedgerInquirableImpl { 040 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BalanceInquirableImpl.class); 041 042 private BusinessObjectDictionaryService dataDictionary; 043 private LookupService lookupService; 044 private Class businessObjectClass; 045 046 /** 047 * Builds the keys for this inquiry. 048 * @return a List of Strings, holding the keys of this inquiry 049 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#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.BALANCE_TYPE_CODE); 058 keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); 059 keys.add(KFSPropertyConstants.OBJECT_CODE); 060 keys.add(KFSPropertyConstants.SUB_OBJECT_CODE); 061 keys.add(KFSPropertyConstants.OBJECT_TYPE_CODE); 062 keys.add(Constant.PENDING_ENTRY_OPTION); 063 064 return keys; 065 } 066 067 /** 068 * The addition of all the month amounts, plus beginning balance and c&g balance as attributes 069 * @return a Map of user defined attributes 070 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap() 071 */ 072 protected Map getUserDefinedAttributeMap() { 073 Map userDefinedAttributeMap = new HashMap(); 074 075 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH1_AMOUNT, KFSConstants.MONTH1); 076 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH2_AMOUNT, KFSConstants.MONTH2); 077 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH3_AMOUNT, KFSConstants.MONTH3); 078 079 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH4_AMOUNT, KFSConstants.MONTH4); 080 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH5_AMOUNT, KFSConstants.MONTH5); 081 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH6_AMOUNT, KFSConstants.MONTH6); 082 083 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH7_AMOUNT, KFSConstants.MONTH7); 084 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH8_AMOUNT, KFSConstants.MONTH8); 085 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH9_AMOUNT, KFSConstants.MONTH9); 086 087 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH10_AMOUNT, KFSConstants.MONTH10); 088 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH11_AMOUNT, KFSConstants.MONTH11); 089 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH12_AMOUNT, KFSConstants.MONTH12); 090 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH13_AMOUNT, KFSConstants.MONTH13); 091 092 userDefinedAttributeMap.put(KFSPropertyConstants.BEGINNING_BALANCE_LINE_AMOUNT, KFSConstants.PERIOD_CODE_BEGINNING_BALANCE); 093 userDefinedAttributeMap.put(KFSPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT, KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE); 094 095 return userDefinedAttributeMap; 096 } 097 098 /** 099 * Changes the name of attributes on the fly...in this case, this just always returns the attribute name it's handed 100 * @param attributeName the attribute to rename 101 * @return a String with the new attribute name 102 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String) 103 */ 104 protected String getAttributeName(String attributeName) { 105 return attributeName; 106 } 107 108 /** 109 * If the key name sent in represents an "exclusive field", returns "" as the key value 110 * @param keyName the name of the key that may be changed 111 * @param keyValue the value of the key that may be changed 112 * @return an Object with the perhaps modified value for the key 113 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object) 114 */ 115 protected Object getKeyValue(String keyName, Object keyValue) { 116 if (isExclusiveField(keyName, keyValue)) { 117 keyValue = Constant.EMPTY_STRING; 118 } 119 return keyValue; 120 } 121 122 /** 123 * Justs returns the key name given 124 * @param keyName a key name 125 * @return the key name given 126 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String) 127 */ 128 protected String getKeyName(String keyName) { 129 keyName = BusinessObjectFieldConverter.convertToTransactionPropertyName(keyName); 130 return keyName; 131 } 132 133 /** 134 * Return a Spring bean for the lookup 135 * @return the name of the Spring bean of the lookup 136 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName() 137 */ 138 protected String getLookupableImplAttributeName() { 139 return Constant.GL_LOOKUPABLE_ENTRY; 140 } 141 142 /** 143 * Return the page name of this lookup 144 * @return the page name for all GL lookups 145 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl() 146 */ 147 protected String getBaseUrl() { 148 return KFSConstants.GL_MODIFIED_INQUIRY_ACTION; 149 } 150 151 /** 152 * Retrieves the business class of the next class type to drill up...since balance summarizes entry, it's entry 153 * @param attributeName the name to build the inquiry link to 154 * @return the Class of the business object that should be inquired on 155 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String) 156 */ 157 protected Class getInquiryBusinessObjectClass(String attributeName) { 158 return Entry.class; 159 } 160 161 /** 162 * Addes the lookup impl and period code attributes to the parameters 163 * @param parameter the parameters used in the lookup 164 * @param attributeName the attribute name that an inquiry URL is being built for 165 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String) 166 */ 167 protected void addMoreParameters(Properties parameter, String attributeName) { 168 parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName()); 169 170 String periodCode = (String) getUserDefinedAttributeMap().get(attributeName); 171 parameter.put(KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME, periodCode); 172 } 173}