Source Code Cross Referenced for LedgerBalanceForExpenseTransferLookupableHelperServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » web » lookupable » 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.lookupable 
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.lookupable;
017:
018:        import java.beans.PropertyDescriptor;
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.apache.commons.beanutils.PropertyUtils;
025:        import org.apache.commons.lang.StringUtils;
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:        import org.kuali.core.bo.BusinessObject;
029:        import org.kuali.core.bo.PersistableBusinessObject;
030:        import org.kuali.core.datadictionary.mask.Mask;
031:        import org.kuali.core.service.AuthorizationService;
032:        import org.kuali.core.util.GlobalVariables;
033:        import org.kuali.core.util.ObjectUtils;
034:        import org.kuali.core.web.comparator.CellComparatorHelper;
035:        import org.kuali.core.web.format.BooleanFormatter;
036:        import org.kuali.core.web.format.Formatter;
037:        import org.kuali.core.web.struts.form.LookupForm;
038:        import org.kuali.core.web.ui.Column;
039:        import org.kuali.core.web.ui.ResultRow;
040:        import org.kuali.kfs.KFSConstants;
041:        import org.kuali.kfs.context.SpringContext;
042:        import org.kuali.module.labor.bo.SegmentedBusinessObject;
043:        import org.kuali.module.labor.web.inquirable.LedgerBalanceForExpenseTransferInquirableImpl;
044:
045:        /**
046:         * Service implementation of LedgerBalanceForExpenseTransferLookupableHelperService.
047:         */
048:
049:        public abstract class LedgerBalanceForExpenseTransferLookupableHelperServiceImpl
050:                extends LedgerBalanceLookupableHelperServiceImpl {
051:            private static final Log LOG = LogFactory
052:                    .getLog(LedgerBalanceForExpenseTransferLookupableHelperServiceImpl.class);
053:
054:            /**
055:             * @see org.kuali.core.lookup.Lookupable#getInquiryUrl(org.kuali.core.bo.BusinessObject, java.lang.String)
056:             */
057:            @Override
058:            public String getInquiryUrl(BusinessObject bo, String propertyName) {
059:                return (new LedgerBalanceForExpenseTransferInquirableImpl())
060:                        .getInquiryUrl(bo, propertyName);
061:            }
062:
063:            /**
064:             * @see org.kuali.module.labor.web.lookupable.LedgerBalanceLookupableHelperServiceImpl#getSearchResults(java.util.Map)
065:             */
066:            @Override
067:            public List<? extends BusinessObject> getSearchResults(
068:                    Map<String, String> fieldValues) {
069:                return null;
070:            }
071:
072:            /**
073:             * This method performs the lookup and returns a collection of lookup items
074:             * 
075:             * @param lookupForm
076:             * @param lookupable
077:             * @param resultTable
078:             * @param bounded
079:             * @return
080:             */
081:            public Collection performLookup(LookupForm lookupForm,
082:                    Collection resultTable, boolean bounded) {
083:                Collection<BusinessObject> displayList;
084:
085:                // call search method to get results
086:                if (bounded) {
087:                    displayList = (Collection<BusinessObject>) getSearchResults(lookupForm
088:                            .getFieldsForLookup());
089:                } else {
090:                    displayList = (Collection<BusinessObject>) getSearchResultsUnbounded(lookupForm
091:                            .getFieldsForLookup());
092:                }
093:
094:                // iterate through result list and wrap rows with return url and action urls
095:                for (BusinessObject element : displayList) {
096:                    LOG.debug("Doing lookup for " + element.getClass());
097:                    String returnUrl = getReturnUrl(element, lookupForm
098:                            .getFieldConversions(), lookupForm
099:                            .getLookupableImplServiceName());
100:
101:                    if (element instanceof  PersistableBusinessObject) {
102:                        if (element instanceof  SegmentedBusinessObject) {
103:                            LOG.debug("segmented property names "
104:                                    + ((SegmentedBusinessObject) element)
105:                                            .getSegmentedPropertyNames());
106:                            for (String propertyName : ((SegmentedBusinessObject) element)
107:                                    .getSegmentedPropertyNames()) {
108:                                Collection<Column> columns = getColumns(element);
109:                                columns.add(setupResultsColumn(element,
110:                                        propertyName));
111:
112:                                ResultRow row = new ResultRow(
113:                                        (List<Column>) columns, returnUrl,
114:                                        getActionUrls(element));
115:
116:                                String extraReturnData = ((SegmentedBusinessObject) element)
117:                                        .getAdditionalReturnData(propertyName);
118:                                row
119:                                        .setObjectId(((PersistableBusinessObject) element)
120:                                                .getObjectId()
121:                                                + "."
122:                                                + propertyName
123:                                                + "."
124:                                                + extraReturnData);
125:                                resultTable.add(row);
126:                            }
127:                        } else {
128:                            Collection<Column> columns = getColumns(element);
129:
130:                            ResultRow row = new ResultRow(
131:                                    (List<Column>) columns, returnUrl,
132:                                    getActionUrls(element));
133:                            row
134:                                    .setObjectId(((PersistableBusinessObject) element)
135:                                            .getObjectId());
136:                            resultTable.add(row);
137:                        }
138:                    }
139:                }
140:
141:                return displayList;
142:            }
143:
144:            /**
145:             * @param element
146:             * @param attributeName
147:             * @return Column
148:             */
149:            protected Column setupResultsColumn(BusinessObject element,
150:                    String attributeName) {
151:                Column col = new Column();
152:
153:                col.setPropertyName(attributeName);
154:
155:                String columnTitle = getDataDictionaryService()
156:                        .getAttributeLabel(getBusinessObjectClass(),
157:                                attributeName);
158:                if (StringUtils.isBlank(columnTitle)) {
159:                    columnTitle = getDataDictionaryService()
160:                            .getCollectionLabel(getBusinessObjectClass(),
161:                                    attributeName);
162:                }
163:                col.setColumnTitle(columnTitle);
164:                col.setMaxLength(getDataDictionaryService()
165:                        .getAttributeMaxLength(getBusinessObjectClass(),
166:                                attributeName));
167:
168:                Class formatterClass = getDataDictionaryService()
169:                        .getAttributeFormatter(getBusinessObjectClass(),
170:                                attributeName);
171:                Formatter formatter = null;
172:                if (formatterClass != null) {
173:                    try {
174:                        formatter = (Formatter) formatterClass.newInstance();
175:                        col.setFormatter(formatter);
176:                    } catch (InstantiationException e) {
177:                        LOG
178:                                .error("Unable to get new instance of formatter class: "
179:                                        + formatterClass.getName());
180:                        throw new RuntimeException(
181:                                "Unable to get new instance of formatter class: "
182:                                        + formatterClass.getName());
183:                    } catch (IllegalAccessException e) {
184:                        LOG
185:                                .error("Unable to get new instance of formatter class: "
186:                                        + formatterClass.getName());
187:                        throw new RuntimeException(
188:                                "Unable to get new instance of formatter class: "
189:                                        + formatterClass.getName());
190:                    }
191:                }
192:
193:                // pick off result column from result list, do formatting
194:                String propValue = KFSConstants.EMPTY_STRING;
195:                Object prop = ObjectUtils.getPropertyValue(element,
196:                        attributeName);
197:
198:                // set comparator and formatter based on property type
199:                Class propClass = null;
200:                try {
201:                    PropertyDescriptor propDescriptor = PropertyUtils
202:                            .getPropertyDescriptor(element, col
203:                                    .getPropertyName());
204:                    if (propDescriptor != null) {
205:                        propClass = propDescriptor.getPropertyType();
206:                    }
207:                } catch (Exception e) {
208:                    throw new RuntimeException(
209:                            "Cannot access PropertyType for property " + "'"
210:                                    + col.getPropertyName() + "' "
211:                                    + " on an instance of '"
212:                                    + element.getClass().getName() + "'.", e);
213:                }
214:
215:                // formatters
216:                if (prop != null) {
217:                    // for Booleans, always use BooleanFormatter
218:                    if (prop instanceof  Boolean) {
219:                        formatter = new BooleanFormatter();
220:                    }
221:
222:                    if (formatter != null) {
223:                        propValue = (String) formatter.format(prop);
224:                    } else {
225:                        propValue = prop.toString();
226:                    }
227:                }
228:
229:                // comparator
230:                col.setComparator(CellComparatorHelper
231:                        .getAppropriateComparatorForPropertyClass(propClass));
232:                col
233:                        .setValueComparator(CellComparatorHelper
234:                                .getAppropriateValueComparatorForPropertyClass(propClass));
235:
236:                // check security on field and do masking if necessary
237:                boolean viewAuthorized = SpringContext.getBean(
238:                        AuthorizationService.class)
239:                        .isAuthorizedToViewAttribute(
240:                                GlobalVariables.getUserSession()
241:                                        .getUniversalUser(),
242:                                element.getClass().getName(),
243:                                col.getPropertyName());
244:                if (!viewAuthorized) {
245:                    Mask displayMask = getDataDictionaryService()
246:                            .getAttributeDisplayMask(
247:                                    element.getClass().getName(),
248:                                    col.getPropertyName());
249:                    propValue = displayMask.maskValue(propValue);
250:                }
251:                col.setPropertyValue(propValue);
252:
253:                if (StringUtils.isNotBlank(propValue)) {
254:                    col.setPropertyURL(getInquiryUrl(element, col
255:                            .getPropertyName()));
256:                }
257:                return col;
258:            }
259:
260:            /**
261:             * Constructs the list of columns for the search results. All properties for the column objects come from the DataDictionary.
262:             * 
263:             * @param bo
264:             * @return Collection<Column>
265:             */
266:            protected Collection<Column> getColumns(BusinessObject bo) {
267:                Collection<Column> columns = new ArrayList<Column>();
268:
269:                for (String attributeName : getBusinessObjectDictionaryService()
270:                        .getLookupResultFieldNames(getBusinessObjectClass())) {
271:                    columns.add(setupResultsColumn(bo, attributeName));
272:                }
273:                return columns;
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.