View Javadoc
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.AccountBalanceByLevel;
27  import org.kuali.ole.sys.OLEConstants;
28  import org.kuali.ole.sys.OLEPropertyConstants;
29  import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
30  import org.kuali.rice.krad.service.LookupService;
31  
32  /**
33   * This class is used to generate the URL for the user-defined attributes for the account balace by consolidation screen. It is
34   * entended the KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation.
35   */
36  public class AccountBalanceByConsolidationInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
37      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByConsolidationInquirableImpl.class);
38  
39      private BusinessObjectDictionaryService dataDictionary;
40      private LookupService lookupService;
41      private Class businessObjectClass;
42  
43      /**
44       * Builds a list of attributes for finding the values for this inquiry.
45       * 
46       * @return a List of attribute keys to inquire on
47       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
48       */
49      protected List buildUserDefinedAttributeKeyList() {
50          List keys = new ArrayList();
51  
52          keys.add(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
53          keys.add(OLEPropertyConstants.ACCOUNT_NUMBER);
54          keys.add(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
55          keys.add(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
56          keys.add("financialObject.financialObjectLevel.financialConsolidationObject.finConsolidationObjectCode");
57          keys.add(Constant.COST_SHARE_OPTION);
58          keys.add(Constant.CONSOLIDATION_OPTION);
59          keys.add(Constant.PENDING_ENTRY_OPTION);
60  
61          return keys;
62      }
63  
64      /**
65       * Generates an attribute map of fields created simply for this inquiry
66       * 
67       * @return a Map with a link button attribute in it
68       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
69       */
70      protected Map getUserDefinedAttributeMap() {
71          Map userDefinedAttributeMap = new HashMap();
72          // userDefinedAttributeMap.put("financialObject.financialObjectLevel.financialConsolidationObject.financialConsolidationObjectCode",
73          // "");
74          userDefinedAttributeMap.put(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION, "");
75          return userDefinedAttributeMap;
76      }
77  
78      /**
79       * Converts attribute names for the inquiry screen
80       * 
81       * @return the converted name of the attribute
82       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
83       */
84      protected String getAttributeName(String attributeName) {
85          // if (attributeName.equals("dummyBusinessObject.linkButtonOption")) {
86          // attributeName = "financialObject.financialObjectLevel";
87          // }
88          return attributeName;
89      }
90  
91      /**
92       * Overrides the key value with a blank string if it's an exclusive value
93       * 
94       * @param keyName the keyName of the key to check
95       * @param keyValue the value of the key to check
96       * @return a new value
97       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
98       */
99      protected Object getKeyValue(String keyName, Object keyValue) {
100         if (isExclusiveField(keyName, keyValue)) {
101             keyValue = "";
102         }
103         return keyValue;
104     }
105 
106     /**
107      * Given a key name, returns the key name; this implementation just passes back what it gets
108      * 
109      * @return the key name passed in
110      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
111      */
112     protected String getKeyName(String keyName) {
113         return keyName;
114     }
115 
116     /**
117      * The name of this inquiry
118      * 
119      * @return a String with this inquiry's name
120      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
121      */
122     protected String getLookupableImplAttributeName() {
123         return Constant.GL_LOOKUPABLE_ACCOUNT_BALANCE_BY_LEVEL;
124     }
125 
126     /**
127      * The base url that inquires of this type need to be sent to
128      * 
129      * @return the base url
130      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
131      */
132     protected String getBaseUrl() {
133         return OLEConstants.GL_MODIFIED_INQUIRY_ACTION;
134     }
135 
136     /**
137      * The business object class this inquiry should be returning for a given attribute - in this case, AccountBalanceByLevel for the LINK_BUTTON_OPTION
138      * 
139      * @param attributeName the attribute to return a class for
140      * @return a class for the attribute
141      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
142      */
143     protected Class getInquiryBusinessObjectClass(String attributeName) {
144         Class c = null;
145         if (GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION.equals(attributeName)) {
146             c = AccountBalanceByLevel.class;
147         }
148         return c;
149     }
150 
151     /**
152      * For a given attribute, lets this inquiry add more parameters
153      * @param parameter the set of parameters for the inquiry
154      * @param attributeName the attributeName parameters are being set for
155      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
156      */
157     protected void addMoreParameters(Properties parameter, String attributeName) {
158         parameter.put(OLEConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
159     }
160 }