Source Code Cross Referenced for BusinessObjectFieldConverter.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » util » 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.gl.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-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.gl.util;
017:
018:        import java.util.ArrayList;
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.kuali.kfs.KFSPropertyConstants;
025:
026:        /**
027:         * This class converts field values from G/L Business Objects to G?L transactions
028:         */
029:        public class BusinessObjectFieldConverter {
030:
031:            /**
032:             * This method converts the field values from normal GL business objects to GL transaction
033:             * 
034:             * @param fields list of fields in GL business object
035:             * @return the list of fields for GL transaction
036:             */
037:            public static List convertToTransactionFields(List fields) {
038:                List transactionFields = new ArrayList();
039:
040:                Iterator propsIter = fields.iterator();
041:                while (propsIter.hasNext()) {
042:                    String propertyName = (String) propsIter.next();
043:
044:                    // convert property name from normal BO to GL transaction
045:                    String transactionPropertyName = propertyName;
046:
047:                    Map propertyMappingTable = getPropertyMappingTable();
048:                    transactionPropertyName = convertPropertyName(
049:                            propertyMappingTable, propertyName);
050:
051:                    // create a new entry for current property
052:                    transactionFields.add(transactionPropertyName);
053:                }
054:                return transactionFields;
055:            }
056:
057:            /**
058:             * This method converts the field values from normal GL business objects to GL transaction
059:             * 
060:             * @param fieldValues the map of field values for normal GL business objects
061:             * @return the map of field values for GL transaction
062:             */
063:            public static Map convertToTransactionFieldValues(Map fieldValues) {
064:                Map transactionFieldValues = new HashMap();
065:
066:                Iterator propsIter = fieldValues.keySet().iterator();
067:                while (propsIter.hasNext()) {
068:                    String propertyName = (String) propsIter.next();
069:                    String propertyValue = (String) fieldValues
070:                            .get(propertyName);
071:
072:                    // convert property name from normal BO to GL transaction
073:                    String transactionPropertyName = propertyName;
074:
075:                    Map propertyMappingTable = getPropertyMappingTable();
076:                    transactionPropertyName = convertPropertyName(
077:                            propertyMappingTable, propertyName);
078:
079:                    // create a new entry for current property
080:                    transactionFieldValues.put(transactionPropertyName,
081:                            propertyValue);
082:                }
083:                return transactionFieldValues;
084:            }
085:
086:            /**
087:             * This method converts the property name of a normal business object to GL transaction
088:             * 
089:             * @param propertyName the property name of a normal business object
090:             * @return the property name of GL transaction
091:             */
092:            public static String convertToTransactionPropertyName(
093:                    String propertyName) {
094:                return convertPropertyName(getPropertyMappingTable(),
095:                        propertyName);
096:            }
097:
098:            /**
099:             * This method converts the property name of a normal business object from GL transaction
100:             * 
101:             * @param propertyName the property name of GL transaction
102:             * @return the property name of a normal business object
103:             */
104:            public static String convertFromTransactionPropertyName(
105:                    String propertyName) {
106:                return convertPropertyName(getSwappedPropertyMappingTable(),
107:                        propertyName);
108:            }
109:
110:            /**
111:             * This method converts the field values from GL transaction to normal GL business objects
112:             * 
113:             * @param fieldValues the map of field values for GL transaction
114:             * @return the map of field values for normal GL business objects
115:             */
116:            public static Map convertFromTransactionFieldValues(Map fieldValues) {
117:                Map boFieldValues = new HashMap();
118:
119:                Iterator propsIter = fieldValues.keySet().iterator();
120:                while (propsIter.hasNext()) {
121:                    String propertyName = (String) propsIter.next();
122:                    String propertyValue = (String) fieldValues
123:                            .get(propertyName);
124:
125:                    // convert property name from normal BO to GL transaction
126:                    String transactionPropertyName = propertyName;
127:                    Map propertyMappingTable = getSwappedPropertyMappingTable();
128:                    transactionPropertyName = convertPropertyName(
129:                            propertyMappingTable, propertyName);
130:
131:                    // create a new entry for current property
132:                    boFieldValues.put(transactionPropertyName, propertyValue);
133:                }
134:                return boFieldValues;
135:            }
136:
137:            /**
138:             * This method defines a table that maps normal properties into transaction properties
139:             * 
140:             * @return a property mapping table
141:             */
142:            private static Map getPropertyMappingTable() {
143:                Map propertyMappingTable = new HashMap();
144:
145:                propertyMappingTable.put(KFSPropertyConstants.OBJECT_CODE,
146:                        KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
147:                propertyMappingTable.put(KFSPropertyConstants.SUB_OBJECT_CODE,
148:                        KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
149:                propertyMappingTable.put(KFSPropertyConstants.OBJECT_TYPE_CODE,
150:                        KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
151:
152:                propertyMappingTable.put(
153:                        KFSPropertyConstants.BALANCE_TYPE_CODE,
154:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
155:                propertyMappingTable.put(
156:                        KFSPropertyConstants.DOCUMENT_TYPE_CODE,
157:                        KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE);
158:                propertyMappingTable.put(KFSPropertyConstants.ORIGIN_CODE,
159:                        KFSPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE);
160:                propertyMappingTable.put(KFSPropertyConstants.DOCUMENT_NUMBER,
161:                        KFSPropertyConstants.DOCUMENT_NUMBER);
162:
163:                return propertyMappingTable;
164:            }
165:
166:            /**
167:             * This method defines a table that maps transaction properties into normal properties
168:             * 
169:             * @return a property mapping table
170:             */
171:            private static Map getSwappedPropertyMappingTable() {
172:                Map propertyMappingTable = getPropertyMappingTable();
173:                Map swappedPropertyMappingTable = new HashMap();
174:
175:                Iterator iterator = propertyMappingTable.keySet().iterator();
176:                while (iterator.hasNext()) {
177:                    String propertyKey = (String) iterator.next();
178:                    String propertyValue = (String) propertyMappingTable
179:                            .get(propertyKey);
180:
181:                    if (propertyValue != null
182:                            && !swappedPropertyMappingTable
183:                                    .containsKey(propertyValue)) {
184:                        swappedPropertyMappingTable.put(propertyValue,
185:                                propertyKey);
186:                    }
187:                }
188:                return swappedPropertyMappingTable;
189:            }
190:
191:            /**
192:             * This method retrieves a name of the given property name from the given mapping table
193:             * 
194:             * @param propertyMappingTable the property mapping table
195:             * @param propertyName the property name of a normal business object
196:             * @return the property name of GL transaction
197:             */
198:            private static String convertPropertyName(Map propertyMappingTable,
199:                    String propertyName) {
200:
201:                String transactionPropertyName = propertyName;
202:                if (propertyMappingTable.containsKey(propertyName)) {
203:                    transactionPropertyName = (String) propertyMappingTable
204:                            .get(propertyName);
205:                }
206:                return transactionPropertyName;
207:            }
208:
209:            /**
210:             * Escapes any special characters in map name/property values
211:             * 
212:             * @param fieldValues map of field keys and their values
213:             * @param specialCharacter special characters to replace
214:             * @param replacement value to replace special characters with
215:             */
216:            public static void escapeSpecialCharacter(Map fieldValues,
217:                    String specialCharacter, String replacement) {
218:                Iterator propsIter = fieldValues.keySet().iterator();
219:                while (propsIter.hasNext()) {
220:                    String propertyName = (String) propsIter.next();
221:                    String propertyValue = (String) fieldValues
222:                            .get(propertyName);
223:
224:                    String propertyValueAfterEscaped = propertyValue
225:                            .replaceAll(specialCharacter, replacement);
226:                    fieldValues.put(propertyName, propertyValueAfterEscaped);
227:                }
228:            }
229:
230:            /**
231:             * Escapes any single quotes in map name/property values
232:             * @param fieldValues
233:             */
234:            public static void escapeSingleQuote(Map fieldValues) {
235:                String specialCharacter = "'";
236:                String replacement = " ";
237:                escapeSpecialCharacter(fieldValues, specialCharacter,
238:                        replacement);
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.