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.businessobject.Entry;
26  import org.kuali.ole.gl.businessobject.lookup.BusinessObjectFieldConverter;
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 GL balace screen. It is entended the
34   * KualiInquirableImpl class, so it covers both the default implementation and customized implemetnation.
35   */
36  public class BalanceInquirableImpl extends AbstractGeneralLedgerInquirableImpl {
37      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BalanceInquirableImpl.class);
38  
39      private BusinessObjectDictionaryService dataDictionary;
40      private LookupService lookupService;
41      private Class businessObjectClass;
42  
43      /**
44       * Builds the keys for this inquiry.
45       * @return a List of Strings, holding the keys of this inquiry
46       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#buildUserDefinedAttributeKeyList()
47       */
48      protected List buildUserDefinedAttributeKeyList() {
49          List keys = new ArrayList();
50  
51          keys.add(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
52          keys.add(OLEPropertyConstants.ACCOUNT_NUMBER);
53          keys.add(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
54          keys.add(OLEPropertyConstants.BALANCE_TYPE_CODE);
55          keys.add(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
56          keys.add(OLEPropertyConstants.OBJECT_CODE);
57          keys.add(OLEPropertyConstants.SUB_OBJECT_CODE);
58          keys.add(OLEPropertyConstants.OBJECT_TYPE_CODE);
59          keys.add(Constant.PENDING_ENTRY_OPTION);
60  
61          return keys;
62      }
63  
64      /**
65       * The addition of all the month amounts, plus beginning balance and c&g balance as attributes
66       * @return a Map of user defined attributes
67       * @see org.kuali.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getUserDefinedAttributeMap()
68       */
69      protected Map getUserDefinedAttributeMap() {
70          Map userDefinedAttributeMap = new HashMap();
71  
72          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH1_AMOUNT, OLEConstants.MONTH1);
73          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH2_AMOUNT, OLEConstants.MONTH2);
74          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH3_AMOUNT, OLEConstants.MONTH3);
75  
76          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH4_AMOUNT, OLEConstants.MONTH4);
77          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH5_AMOUNT, OLEConstants.MONTH5);
78          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH6_AMOUNT, OLEConstants.MONTH6);
79  
80          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH7_AMOUNT, OLEConstants.MONTH7);
81          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH8_AMOUNT, OLEConstants.MONTH8);
82          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH9_AMOUNT, OLEConstants.MONTH9);
83  
84          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH10_AMOUNT, OLEConstants.MONTH10);
85          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH11_AMOUNT, OLEConstants.MONTH11);
86          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH12_AMOUNT, OLEConstants.MONTH12);
87          userDefinedAttributeMap.put(OLEPropertyConstants.MONTH13_AMOUNT, OLEConstants.MONTH13);
88  
89          userDefinedAttributeMap.put(OLEPropertyConstants.BEGINNING_BALANCE_LINE_AMOUNT, OLEConstants.PERIOD_CODE_BEGINNING_BALANCE);
90          userDefinedAttributeMap.put(OLEPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT, OLEConstants.PERIOD_CODE_CG_BEGINNING_BALANCE);
91  
92          return userDefinedAttributeMap;
93      }
94  
95      /**
96       * Changes the name of attributes on the fly...in this case, this just always returns the attribute name it's handed
97       * @param attributeName the attribute to rename
98       * @return a String with the new attribute name
99       * @see org.kuali.ole.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.ole.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.ole.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.ole.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.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#getBaseUrl()
143      */
144     protected String getBaseUrl() {
145         return OLEConstants.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.ole.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.ole.gl.businessobject.inquiry.AbstractGeneralLedgerInquirableImpl#addMoreParameters(java.util.Properties, java.lang.String)
163      */
164     protected void addMoreParameters(Properties parameter, String attributeName) {
165         parameter.put(OLEConstants.LOOKUPABLE_IMPL_ATTRIBUTE_NAME, getLookupableImplAttributeName());
166 
167         String periodCode = (String) getUserDefinedAttributeMap().get(attributeName);
168         parameter.put(OLEConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME, periodCode);
169     }
170 }