001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.gl.businessobject.inquiry; 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.kfs.gl.Constant; 025 import org.kuali.kfs.gl.businessobject.Entry; 026 import org.kuali.kfs.gl.businessobject.lookup.BusinessObjectFieldConverter; 027 import org.kuali.kfs.sys.KFSConstants; 028 import org.kuali.kfs.sys.KFSPropertyConstants; 029 import org.kuali.rice.kns.service.BusinessObjectDictionaryService; 030 import org.kuali.rice.kns.service.LookupService; 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 AbstractGeneralLedgerInquirableImpl { 037 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BalanceInquirableImpl.class); 038 039 private BusinessObjectDictionaryService dataDictionary; 040 private LookupService lookupService; 041 private Class businessObjectClass; 042 043 /** 044 * Builds the keys for this inquiry. 045 * @return a List of Strings, holding the keys of this inquiry 046 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList() 047 */ 048 protected List buildUserDefinedAttributeKeyList() { 049 List keys = new ArrayList(); 050 051 keys.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR); 052 keys.add(KFSPropertyConstants.ACCOUNT_NUMBER); 053 keys.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE); 054 keys.add(KFSPropertyConstants.BALANCE_TYPE_CODE); 055 keys.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER); 056 keys.add(KFSPropertyConstants.OBJECT_CODE); 057 keys.add(KFSPropertyConstants.SUB_OBJECT_CODE); 058 keys.add(KFSPropertyConstants.OBJECT_TYPE_CODE); 059 keys.add(Constant.PENDING_ENTRY_OPTION); 060 061 return keys; 062 } 063 064 /** 065 * The addition of all the month amounts, plus beginning balance and c&g balance as attributes 066 * @return a Map of user defined attributes 067 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap() 068 */ 069 protected Map getUserDefinedAttributeMap() { 070 Map userDefinedAttributeMap = new HashMap(); 071 072 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH1_AMOUNT, KFSConstants.MONTH1); 073 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH2_AMOUNT, KFSConstants.MONTH2); 074 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH3_AMOUNT, KFSConstants.MONTH3); 075 076 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH4_AMOUNT, KFSConstants.MONTH4); 077 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH5_AMOUNT, KFSConstants.MONTH5); 078 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH6_AMOUNT, KFSConstants.MONTH6); 079 080 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH7_AMOUNT, KFSConstants.MONTH7); 081 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH8_AMOUNT, KFSConstants.MONTH8); 082 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH9_AMOUNT, KFSConstants.MONTH9); 083 084 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH10_AMOUNT, KFSConstants.MONTH10); 085 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH11_AMOUNT, KFSConstants.MONTH11); 086 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH12_AMOUNT, KFSConstants.MONTH12); 087 userDefinedAttributeMap.put(KFSPropertyConstants.MONTH13_AMOUNT, KFSConstants.MONTH13); 088 089 userDefinedAttributeMap.put(KFSPropertyConstants.BEGINNING_BALANCE_LINE_AMOUNT, KFSConstants.PERIOD_CODE_BEGINNING_BALANCE); 090 userDefinedAttributeMap.put(KFSPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT, KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE); 091 092 return userDefinedAttributeMap; 093 } 094 095 /** 096 * Changes the name of attributes on the fly...in this case, this just always returns the attribute name it's handed 097 * @param attributeName the attribute to rename 098 * @return a String with the new attribute name 099 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String) 100 */ 101 protected String getAttributeName(String attributeName) { 102 return attributeName; 103 } 104 105 /** 106 * If the key name sent in represents an "exclusive field", returns "" as the key value 107 * @param keyName the name of the key that may be changed 108 * @param keyValue the value of the key that may be changed 109 * @return an Object with the perhaps modified value for the key 110 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object) 111 */ 112 protected Object getKeyValue(String keyName, Object keyValue) { 113 if (isExclusiveField(keyName, keyValue)) { 114 keyValue = Constant.EMPTY_STRING; 115 } 116 return keyValue; 117 } 118 119 /** 120 * Justs returns the key name given 121 * @param keyName a key name 122 * @return the key name given 123 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String) 124 */ 125 protected String getKeyName(String keyName) { 126 keyName = BusinessObjectFieldConverter.convertToTransactionPropertyName(keyName); 127 return keyName; 128 } 129 130 /** 131 * Return a Spring bean for the lookup 132 * @return the name of the Spring bean of the lookup 133 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName() 134 */ 135 protected String getLookupableImplAttributeName() { 136 return Constant.GL_LOOKUPABLE_ENTRY; 137 } 138 139 /** 140 * Return the page name of this lookup 141 * @return the page name for all GL lookups 142 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl() 143 */ 144 protected String getBaseUrl() { 145 return KFSConstants.GL_MODIFIED_INQUIRY_ACTION; 146 } 147 148 /** 149 * Retrieves the business class of the next class type to drill up...since balance summarizes entry, it's entry 150 * @param attributeName the name to build the inquiry link to 151 * @return the Class of the business object that should be inquired on 152 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String) 153 */ 154 protected Class getInquiryBusinessObjectClass(String attributeName) { 155 return Entry.class; 156 } 157 158 /** 159 * Addes the lookup impl and period code attributes to the parameters 160 * @param parameter the parameters used in the lookup 161 * @param attributeName the attribute name that an inquiry URL is being built for 162 * @see org.kuali.kfs.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String) 163 */ 164 protected void addMoreParameters(Properties parameter, String attributeName) { 165 parameter.put(KFSConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName()); 166 167 String periodCode = (String) getUserDefinedAttributeMap().get(attributeName); 168 parameter.put(KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME, periodCode); 169 } 170 }