1 /*
2 * Copyright 2006 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.gl.businessobject.inquiry;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.Properties;
23
24 import org.kuali.ole.gl.Constant;
25 import org.kuali.ole.gl.businessobject.Balance;
26 import org.kuali.ole.sys.OLEConstants;
27 import org.kuali.ole.sys.OLEPropertyConstants;
28 import org.kuali.ole.sys.businessobject.SystemOptions;
29 import org.kuali.ole.sys.context.SpringContext;
30 import org.kuali.ole.sys.service.OptionsService;
31 import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
32 import org.kuali.rice.krad.service.LookupService;
33
34 /**
35 * This class is used to generate the URL for the user-defined attributes for available account balace screen. It is entended the
36 * AbstractGeneralLedgerInquirableImpl class, so it covers both the default implementation and customized implemetnation.
37 */
38 public class AccountBalanceInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
39 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceInquirableImpl.class);
40
41 private BusinessObjectDictionaryService dataDictionary;
42 private LookupService lookupService;
43 private Class businessObjectClass;
44
45 /**
46 * Builds the keys for this inquiry.
47 * @return a List of Strings, holding the keys of this inquiry
48 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
49 */
50 protected List buildUserDefinedAttributeKeyList() {
51 List keys = new ArrayList();
52
53 keys.add(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
54 keys.add(OLEPropertyConstants.ACCOUNT_NUMBER);
55 keys.add(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
56 keys.add(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
57 keys.add(OLEPropertyConstants.OBJECT_CODE);
58 keys.add(OLEPropertyConstants.SUB_OBJECT_CODE);
59 keys.add(Constant.CONSOLIDATION_OPTION);
60 keys.add(Constant.PENDING_ENTRY_OPTION);
61
62 return keys;
63 }
64
65 /**
66 * The addition of user attributes - current budget, actual budget, and encumbrance balance
67 * @return a Map of user defined attributes
68 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
69 */
70 protected Map getUserDefinedAttributeMap() {
71 Map userDefinedAttributeMap = new HashMap();
72
73 OptionsService os = SpringContext.getBean(OptionsService.class);
74 SystemOptions o = os.getCurrentYearOptions();
75
76 userDefinedAttributeMap.put(OLEPropertyConstants.CURRENT_BUDGET_LINE_BALANCE_AMOUNT, Constant.BALANCE_TYPE_CB);
77 userDefinedAttributeMap.put(OLEPropertyConstants.ACCOUNT_LINE_ACTUALS_BALANCE_AMOUNT, o.getActualFinancialBalanceTypeCd());
78 userDefinedAttributeMap.put(OLEPropertyConstants.ACCOUNT_LINE_ENCUMBRANCE_BALANCE_AMOUNT, OLEConstants.AGGREGATE_ENCUMBRANCE_BALANCE_TYPE_CODE);
79
80 return userDefinedAttributeMap;
81 }
82
83 /**
84 * Changes the name of attributes on the fly...in this case, doesn't do anything
85 * @param attributeName the attribute to rename
86 * @return a String with the new attribute name
87 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
88 */
89 protected String getAttributeName(String attributeName) {
90 return attributeName;
91 }
92
93 /**
94 * If the key name sent in represents an "exclusive field", returns "" as the key value
95 * @param keyName the name of the key that may be changed
96 * @param keyValue the value of the key that may be changed
97 * @return an Object with the perhaps modified value for the key
98 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
99 */
100 protected Object getKeyValue(String keyName, Object keyValue) {
101 if (isExclusiveField(keyName, keyValue)) {
102 keyValue = "";
103 }
104 return keyValue;
105 }
106
107 /**
108 * Justs returns the key name given
109 * @param keyName a key name
110 * @return the key name given
111 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
112 */
113 protected String getKeyName(String keyName) {
114 return keyName;
115 }
116
117 /**
118 * Return a Spring bean for the drill up lookup, which is the balance lookup
119 * @return the name of the Spring bean of the lookup
120 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
121 */
122 protected String getLookupableImplAttributeName() {
123 return Constant.GL_LOOKUPABLE_BALANCE;
124 }
125
126 /**
127 * Return the page name of this lookup
128 * @return the page name for inquiry options
129 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
130 */
131 protected String getBaseUrl() {
132 return OLEConstants.GL_BALANCE_INQUIRY_ACTION;
133 }
134
135 /**
136 * Retrieves the business class to use as the basis of an inquiry for the given attribute; in this case, it's always Balance
137 * @param attributeName the name to build the inquiry link to
138 * @return the Class of the business object that should be inquired on
139 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
140 */
141 protected Class getInquiryBusinessObjectClass(String attributeName) {
142 return Balance.class;
143 }
144
145 /**
146 * Addes the lookup impl and balance type attributes to the parameters
147 * @param parameter the parameters used in the lookup
148 * @param attributeName the attribute name that an inquiry URL is being built for
149 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
150 */
151 protected void addMoreParameters(Properties parameter, String attributeName) {
152 parameter.put(OLEConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
153 parameter.put(Constant.AMOUNT_VIEW_OPTION, Constant.MONTHLY);
154
155 String balanceTypeCode = (String) getUserDefinedAttributeMap().get(getAttributeName(attributeName));
156 parameter.put(OLEPropertyConstants.BALANCE_TYPE_CODE, balanceTypeCode);
157 }
158 }