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.AccountBalanceByObject;
27  import org.kuali.ole.gl.businessobject.lookup.BusinessObjectFieldConverter;
28  import org.kuali.ole.sys.OLEConstants;
29  import org.kuali.ole.sys.OLEPropertyConstants;
30  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
31  
32  /**
33   * This class is used to generate the URL for the user-defined attributes for the account balace by object screen. It is entended
34   * the AbstractGeneralLedgerInquirableImpl class, so it covers both the default implementation and customized implemetnation.
35   */
36  public class AccountBalanceByObjectInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
37      @SuppressWarnings("unused")
38      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByObjectInquirableImpl.class);
39  
40      /**
41       * Builds the keys for this inquiry.
42       * @return a List of Strings, holding the keys of this inquiry
43       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
44       */
45      protected List buildUserDefinedAttributeKeyList() {
46          List keys = new ArrayList();
47  
48          keys.add(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
49          keys.add(OLEPropertyConstants.ACCOUNT_NUMBER);
50          keys.add(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
51          keys.add(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
52          keys.add(OLEPropertyConstants.OBJECT_CODE);
53          keys.add(OLEPropertyConstants.SUB_OBJECT_CODE);
54          keys.add(Constant.COST_SHARE_OPTION);
55          keys.add(Constant.CONSOLIDATION_OPTION);
56  
57          return keys;
58      }
59  
60      /**
61       * The addition of a couple attributes to the lookup - object code, object level, and link button
62       * @return a Map of user defined attributes
63       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
64       */
65      protected Map getUserDefinedAttributeMap() {
66          Map userDefinedAttributeMap = new HashMap();
67          userDefinedAttributeMap.put(OLEPropertyConstants.FINANCIAL_OBJECT_CODE, "");
68          userDefinedAttributeMap.put(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION, "");
69          userDefinedAttributeMap.put(GeneralLedgerConstants.BalanceInquiryDrillDowns.OBJECT_LEVEL_CODE, "");
70          return userDefinedAttributeMap;
71      }
72  
73      /**
74       * Changes the name of attributes on the fly...in this case, turns the link button to display its name as glpe
75       * @param attributeName the attribute to rename
76       * @return a String with the new attribute name
77       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getAttributeName(java.lang.String)
78       */
79      protected String getAttributeName(String attributeName) {
80          if (attributeName.equals(GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION)) {
81              attributeName = OLEPropertyConstants.GENERAL_LEDGER_PENDING_ENTRY;
82          }
83          return attributeName;
84      }
85  
86      /**
87       * If the key name sent in represents an "exclusive field", returns "" as the key value
88       * @param keyName the name of the key that may be changed
89       * @param keyValue the value of the key that may be changed
90       * @return an Object with the perhaps modified value for the key
91       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyValue(java.lang.String, java.lang.Object)
92       */
93      protected Object getKeyValue(String keyName, Object keyValue) {
94          if (isExclusiveField(keyName, keyValue)) {
95              keyValue = "";
96          }
97          return keyValue;
98      }
99  
100     /**
101      * Justs returns the key name given
102      * @param keyName a key name
103      * @return the key name given
104      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getKeyName(java.lang.String)
105      */
106     protected String getKeyName(String keyName) {
107         keyName = BusinessObjectFieldConverter.convertToTransactionPropertyName(keyName);
108         return keyName;
109     }
110 
111     /**
112      * Return a Spring bean for the lookup
113      * @return the name of the Spring bean of the lookup
114      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getLookupableImplAttributeName()
115      */
116     protected String getLookupableImplAttributeName() {
117         return Constant.GL_LOOKUPABLE_PENDING_ENTRY;
118     }
119 
120     /**
121      * Return the page name of this lookup
122      * @return the page name for all GL lookups
123      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
124      */
125     protected String getBaseUrl() {
126         return OLEConstants.GL_MODIFIED_INQUIRY_ACTION;
127     }
128 
129     /**
130      * Retrieves the business class to use as the basis of an inquiry for the given attribute
131      * @param attributeName the name to build the inquiry link to
132      * @return the Class of the business object that should be inquired on
133      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getInquiryBusinessObjectClass(String)
134      */
135     protected Class getInquiryBusinessObjectClass(String attributeName) {
136         if (OLEPropertyConstants.GENERAL_LEDGER_PENDING_ENTRY.equals(attributeName)) {
137             return GeneralLedgerPendingEntry.class;
138         }
139         return AccountBalanceByObject.class;
140     }
141 
142     /**
143      * Addes the lookup impl attribute to the parameters
144      * @param parameter the parameters used in the lookup
145      * @param attributeName the attribute name that an inquiry URL is being built for
146      * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
147      */
148     protected void addMoreParameters(Properties parameter, String attributeName) {
149         parameter.put(OLEConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
150     }
151 }