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.GeneralLedgerConstants;
26 import org.kuali.ole.gl.businessobject.AccountBalance;
27 import org.kuali.ole.gl.businessobject.AccountBalanceByLevel;
28 import org.kuali.ole.gl.businessobject.AccountBalanceByObject;
29 import org.kuali.ole.sys.OLEConstants;
30 import org.kuali.ole.sys.OLEPropertyConstants;
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 the account balace by level screen. It is entended the
36 * KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation.
37 */
38 public class AccountBalanceByLevelInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
39 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByLevelInquirableImpl.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(GeneralLedgerConstants.BalanceInquiryDrillDowns.OBJECT_LEVEL_CODE);
58 keys.add(GeneralLedgerConstants.BalanceInquiryDrillDowns.REPORTING_SORT_CODE);
59 keys.add(Constant.COST_SHARE_OPTION);
60 keys.add(Constant.CONSOLIDATION_OPTION);
61 keys.add(Constant.PENDING_ENTRY_OPTION);
62
63 return keys;
64 }
65
66 /**
67 * The addition of the link button
68 * @return a Map of user defined attributes
69 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
70 */
71 protected Map getUserDefinedAttributeMap() {
72 Map userDefinedAttributeMap = new HashMap();
73 userDefinedAttributeMap.put(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION, "");
74 return userDefinedAttributeMap;
75 }
76
77 /**
78 * Changes the name of attributes on the fly...in this case, turns the link button to display its name as object code
79 * @param attributeName the attribute to rename
80 * @return a String with the new attribute name
81 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
82 */
83 protected String getAttributeName(String attributeName) {
84 if (attributeName.equals(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION)) {
85 attributeName = OLEPropertyConstants.OBJECT_CODE;
86 }
87 return attributeName;
88 }
89
90 /**
91 * If the key name sent in represents an "exclusive field", returns "" as the key value
92 * @param keyName the name of the key that may be changed
93 * @param keyValue the value of the key that may be changed
94 * @return an Object with the perhaps modified value for the key
95 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
96 */
97 protected Object getKeyValue(String keyName, Object keyValue) {
98 if (isExclusiveField(keyName, keyValue)) {
99 keyValue = "";
100 }
101 return keyValue;
102 }
103
104 /**
105 * Justs returns the key name given
106 * @param keyName a key name
107 * @return the key name given
108 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
109 */
110 protected String getKeyName(String keyName) {
111 return keyName;
112 }
113
114 /**
115 * Return a Spring bean for the lookup
116 * @return the name of the Spring bean of the lookup
117 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
118 */
119 protected String getLookupableImplAttributeName() {
120 return Constant.GL_LOOKUPABLE_ACCOUNT_BALANCE_BY_OBJECT;
121 }
122
123 /**
124 * Return the page name of this lookup
125 * @return the page name for all GL lookups
126 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
127 */
128 protected String getBaseUrl() {
129 return OLEConstants.GL_MODIFIED_INQUIRY_ACTION;
130 }
131
132 /**
133 * Retrieves the business class to use as the basis of an inquiry for the given attribute
134 * @param attributeName the name to build the inquiry link to
135 * @return the Class of the business object that should be inquired on
136 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
137 */
138 protected Class getInquiryBusinessObjectClass(String attributeName) {
139 Class c = null;
140 /*
141 * if("financialObject.financialObjectLevel.financialConsolidationObjectCode".equals(attributeName)) { c =
142 * AccountBalanceByConsolidation.class; } else
143 */if (GeneralLedgerConstants.BalanceInquiryDrillDowns.OBJECT_LEVEL_CODE.equals(attributeName)) {
144 c = AccountBalance.class;
145 }
146 else if (OLEPropertyConstants.OBJECT_CODE.equals(attributeName)) {
147 c = AccountBalanceByObject.class;
148 }
149 else {
150 c = AccountBalanceByLevel.class;
151 }
152
153 return c;
154 }
155
156 /**
157 * Addes the lookup impl attribute to the parameters
158 * @param parameter the parameters used in the lookup
159 * @param attributeName the attribute name that an inquiry URL is being built for
160 * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
161 */
162 protected void addMoreParameters(Properties parameter, String attributeName) {
163 parameter.put(OLEConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
164 }
165 }