Source Code Cross Referenced for AbstractLaborInquirableImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » web » inquirable » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.labor.web.inquirable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.module.labor.web.inquirable;
017:
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.List;
021:        import java.util.Map;
022:        import java.util.Properties;
023:
024:        import org.kuali.core.bo.BusinessObject;
025:        import org.kuali.core.lookup.LookupUtils;
026:        import org.kuali.core.service.BusinessObjectDictionaryService;
027:        import org.kuali.core.service.PersistenceStructureService;
028:        import org.kuali.core.util.ObjectUtils;
029:        import org.kuali.core.util.UrlFactory;
030:        import org.kuali.kfs.KFSConstants;
031:        import org.kuali.kfs.KFSPropertyConstants;
032:        import org.kuali.kfs.context.SpringContext;
033:        import org.kuali.kfs.inquiry.KfsInquirableImpl;
034:        import org.kuali.module.chart.bo.KualiSystemCode;
035:        import org.kuali.module.gl.web.Constant;
036:        import org.kuali.module.labor.LaborConstants;
037:
038:        /**
039:         * This class is the template class for the customized inqurable implementations used to generate balance inquiry screens.
040:         */
041:        public abstract class AbstractLaborInquirableImpl extends
042:                KfsInquirableImpl {
043:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
044:                    .getLogger(AbstractLaborInquirableImpl.class);
045:
046:            /**
047:             * Helper method to build an inquiry url for a result field.
048:             * 
049:             * @param businessObject the business object instance to build the urls for
050:             * @param attributeName the attribute name which links to an inquirable
051:             * @return String url to inquiry
052:             */
053:            public String getInquiryUrl(BusinessObject businessObject,
054:                    String attributeName) {
055:                BusinessObjectDictionaryService businessDictionary = SpringContext
056:                        .getBean(BusinessObjectDictionaryService.class);
057:                PersistenceStructureService persistenceStructureService = SpringContext
058:                        .getBean(PersistenceStructureService.class);
059:
060:                String baseUrl = KFSConstants.INQUIRY_ACTION;
061:                Properties parameters = new Properties();
062:                parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER,
063:                        KFSConstants.START_METHOD);
064:
065:                Object attributeValue = null;
066:                Class inquiryBusinessObjectClass = null;
067:                String attributeRefName = Constant.EMPTY_STRING;
068:                boolean isPkReference = false;
069:
070:                Map userDefinedAttributeMap = getUserDefinedAttributeMap();
071:                boolean isUserDefinedAttribute = userDefinedAttributeMap == null ? false
072:                        : userDefinedAttributeMap.containsKey(attributeName);
073:
074:                // determine the type of the given attribute: user-defined, regular, nested-referenced or primitive reference
075:                if (isUserDefinedAttribute) {
076:                    attributeName = getAttributeName(attributeName);
077:                    inquiryBusinessObjectClass = getInquiryBusinessObjectClass(attributeName);
078:                    isPkReference = true;
079:                } else if (attributeName.equals(businessDictionary
080:                        .getTitleAttribute(businessObject.getClass()))) {
081:                    inquiryBusinessObjectClass = businessObject.getClass();
082:                    isPkReference = true;
083:                } else if (ObjectUtils.isNestedAttribute(attributeName)) {
084:                    return Constant.EMPTY_STRING;
085:                } else {
086:                    Map primitiveReference = LookupUtils.getPrimitiveReference(
087:                            businessObject, attributeName);
088:                    if (primitiveReference != null
089:                            && !primitiveReference.isEmpty()) {
090:                        attributeRefName = (String) primitiveReference.keySet()
091:                                .iterator().next();
092:                        inquiryBusinessObjectClass = (Class) primitiveReference
093:                                .get(attributeRefName);
094:                    }
095:                    attributeValue = ObjectUtils.getPropertyValue(
096:                            businessObject, attributeName);
097:                    attributeValue = (attributeValue == null) ? ""
098:                            : attributeValue.toString();
099:                }
100:
101:                // process the business object class if the attribute name is not user-defined
102:                if (!isUserDefinedAttribute) {
103:                    if (isExclusiveFieldToBeALink(attributeName, attributeValue)) {
104:                        return Constant.EMPTY_STRING;
105:                    }
106:
107:                    if (inquiryBusinessObjectClass == null
108:                            || businessDictionary
109:                                    .isInquirable(inquiryBusinessObjectClass) == null
110:                            || !businessDictionary.isInquirable(
111:                                    inquiryBusinessObjectClass).booleanValue()) {
112:                        return Constant.EMPTY_STRING;
113:                    }
114:
115:                    if (KualiSystemCode.class
116:                            .isAssignableFrom(inquiryBusinessObjectClass)) {
117:                        inquiryBusinessObjectClass = KualiSystemCode.class;
118:                    }
119:                }
120:                parameters.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE,
121:                        inquiryBusinessObjectClass.getName());
122:
123:                List keys = new ArrayList();
124:                if (isUserDefinedAttribute) {
125:                    baseUrl = getBaseUrl();
126:                    keys = buildUserDefinedAttributeKeyList();
127:
128:                    parameters.put(KFSConstants.RETURN_LOCATION_PARAMETER,
129:                            Constant.RETURN_LOCATION_VALUE);
130:                    parameters
131:                            .put(KFSConstants.GL_BALANCE_INQUIRY_FLAG, "true");
132:                    parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER,
133:                            KFSConstants.SEARCH_METHOD);
134:                    parameters.put(KFSConstants.DOC_FORM_KEY, "88888888");
135:
136:                    // add more customized parameters into the current parameter map
137:                    addMoreParameters(parameters, attributeName);
138:                } else if (persistenceStructureService
139:                        .isPersistable(inquiryBusinessObjectClass)) {
140:                    keys = persistenceStructureService
141:                            .listPrimaryKeyFieldNames(inquiryBusinessObjectClass);
142:                }
143:
144:                // build key value url parameters used to retrieve the business object
145:                if (keys != null) {
146:                    for (Iterator keyIterator = keys.iterator(); keyIterator
147:                            .hasNext();) {
148:                        String keyName = (String) keyIterator.next();
149:
150:                        // convert the key names based on their formats and types
151:                        String keyConversion = keyName;
152:                        if (ObjectUtils.isNestedAttribute(attributeName)) {
153:                            if (isUserDefinedAttribute) {
154:                                keyConversion = keyName;
155:                            } else {
156:                                keyConversion = ObjectUtils
157:                                        .getNestedAttributePrefix(attributeName)
158:                                        + "." + keyName;
159:                            }
160:                        } else {
161:                            if (isPkReference) {
162:                                keyConversion = keyName;
163:                            } else {
164:                                keyConversion = persistenceStructureService
165:                                        .getForeignKeyFieldName(businessObject
166:                                                .getClass(), attributeRefName,
167:                                                keyName);
168:                            }
169:                        }
170:
171:                        Object keyValue = ObjectUtils.getPropertyValue(
172:                                businessObject, keyConversion);
173:                        keyValue = (keyValue == null) ? Constant.EMPTY_STRING
174:                                : keyValue.toString();
175:
176:                        // convert the key value and name into the given ones
177:                        Object tempKeyValue = this .getKeyValue(keyName,
178:                                keyValue);
179:                        keyValue = tempKeyValue == null ? keyValue
180:                                : tempKeyValue;
181:
182:                        String tempKeyName = this .getKeyName(keyName);
183:                        keyName = tempKeyName == null ? keyName : tempKeyName;
184:
185:                        // add the key-value pair into the parameter map
186:                        if (keyName != null)
187:                            parameters.put(keyName, keyValue);
188:                    }
189:                }
190:
191:                return UrlFactory.parameterizeUrl(baseUrl, parameters);
192:            }
193:
194:            /**
195:             * This method builds the inquiry url for user-defined attribute
196:             * 
197:             * @return key list
198:             */
199:            protected abstract List buildUserDefinedAttributeKeyList();
200:
201:            /**
202:             * This method defines the user-defined attribute map
203:             * 
204:             * @return the user-defined attribute map
205:             */
206:            protected abstract Map getUserDefinedAttributeMap();
207:
208:            /**
209:             * This method finds the matching attribute name of given one
210:             * 
211:             * @param attributeName the given attribute name
212:             * @return the attribute name from the given one
213:             */
214:            protected abstract String getAttributeName(String attributeName);
215:
216:            /**
217:             * This method finds the matching the key value of the given one
218:             * 
219:             * @param keyName the given key name
220:             * @param keyValue the given key value
221:             * @return the key value from the given key value
222:             */
223:            protected abstract Object getKeyValue(String keyName,
224:                    Object keyValue);
225:
226:            /**
227:             * This method finds the matching the key name of the given one
228:             * 
229:             * @param keyName the given key name
230:             * @return the key value from the given key name
231:             */
232:            protected abstract String getKeyName(String keyName);
233:
234:            /**
235:             * This method defines the lookupable implementation attribute name
236:             * 
237:             * @return the lookupable implementation attribute name
238:             */
239:            protected abstract String getLookupableImplAttributeName();
240:
241:            /**
242:             * This method defines the base inquiry url
243:             * 
244:             * @return the base inquiry url
245:             */
246:            protected abstract String getBaseUrl();
247:
248:            /**
249:             * This method gets the class name of the inquiry business object for a given attribute.
250:             * 
251:             * @return the class name of the inquiry business object for a given attribute
252:             */
253:            protected abstract Class getInquiryBusinessObjectClass(
254:                    String attributeName);
255:
256:            /**
257:             * This method adds more parameters into the curren parameter map
258:             * 
259:             * @param parameter the current parameter map
260:             */
261:            protected void addMoreParameters(Properties parameter,
262:                    String attributeName) {
263:                return;
264:            }
265:
266:            /**
267:             * This method determines whether the input name-value pair is exclusive from the processing
268:             * 
269:             * @param keyName the name of the name-value pair
270:             * @param keyValue the value of the name-value pair
271:             * @return true if the input key is in the exclusive list; otherwise, false
272:             */
273:            protected boolean isExclusiveField(Object keyName, Object keyValue) {
274:
275:                if (keyName != null && keyValue != null) {
276:
277:                    if (keyName.equals(KFSPropertyConstants.SUB_ACCOUNT_NUMBER)
278:                            && keyValue
279:                                    .equals(Constant.CONSOLIDATED_SUB_ACCOUNT_NUMBER)) {
280:                        return true;
281:                    } else if (keyName
282:                            .equals(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE)
283:                            && keyValue
284:                                    .equals(Constant.CONSOLIDATED_SUB_OBJECT_CODE)) {
285:                        return true;
286:                    } else if (keyName
287:                            .equals(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE)
288:                            && keyValue
289:                                    .equals(Constant.CONSOLIDATED_OBJECT_TYPE_CODE)) {
290:                        return true;
291:                    }
292:                }
293:                return false;
294:            }
295:
296:            /**
297:             * This method determines whether the input name-value pair is exclusive to be a link
298:             * 
299:             * @param keyName the name of the name-value pair
300:             * @param keyValue the value of the name-value pair
301:             * @return true if the input key is in the exclusive list; otherwise, false
302:             */
303:            protected boolean isExclusiveFieldToBeALink(Object keyName,
304:                    Object keyValue) {
305:
306:                if (keyName != null && keyValue != null) {
307:
308:                    if (isExclusiveField(keyName, keyValue)) {
309:                        return true;
310:                    } else if (keyName
311:                            .equals(KFSPropertyConstants.SUB_ACCOUNT_NUMBER)
312:                            && keyValue.equals(KFSConstants
313:                                    .getDashSubAccountNumber())) {
314:                        return true;
315:                    } else if (keyName
316:                            .equals(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE)
317:                            && keyValue.equals(KFSConstants
318:                                    .getDashFinancialSubObjectCode())) {
319:                        return true;
320:                    } else if (keyName
321:                            .equals(KFSPropertyConstants.PROJECT_CODE)
322:                            && keyValue.equals(KFSConstants
323:                                    .getDashProjectCode())) {
324:                        return true;
325:                    } else if (keyName
326:                            .equals(KFSPropertyConstants.POSITION_NUMBER)
327:                            && keyValue.equals(KFSConstants
328:                                    .getDashPositionNumber())) {
329:                        return true;
330:                    } else if (keyName
331:                            .equals(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE)
332:                            && keyValue
333:                                    .equals(LaborConstants.BalanceInquiries.BALANCE_TYPE_AC_AND_A21)) {
334:                        return true;
335:                    }
336:                }
337:                return false;
338:            }
339:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.