Source Code Cross Referenced for ReconciliationDaoOjb.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » dao » ojb » 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.dao.ojb 
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.gl.dao.ojb;
017:
018:        import java.util.ArrayList;
019:        import java.util.List;
020:
021:        import org.apache.ojb.broker.metadata.ClassDescriptor;
022:        import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
023:        import org.apache.ojb.broker.metadata.DescriptorRepository;
024:        import org.apache.ojb.broker.metadata.FieldDescriptor;
025:        import org.apache.ojb.broker.metadata.MetadataManager;
026:        import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
027:        import org.kuali.core.exceptions.ClassNotPersistableException;
028:        import org.kuali.module.gl.bo.OriginEntryFull;
029:        import org.kuali.module.gl.dao.ReconciliationDao;
030:
031:        /**
032:         * Uses OJB to determine the column name -> java attribute name mapping
033:         */
034:        public class ReconciliationDaoOjb extends PlatformAwareDaoBaseOjb
035:                implements  ReconciliationDao {
036:
037:            private DescriptorRepository descriptorRepository;
038:
039:            /**
040:             * Constructs a ReconciliationDaoOjb.java.
041:             */
042:            public ReconciliationDaoOjb() {
043:                MetadataManager metadataManager = MetadataManager.getInstance();
044:                descriptorRepository = metadataManager.getGlobalRepository();
045:            }
046:
047:            /**
048:             * Converts a list of DB column names to a list of java attribute names. The returned list is the same size as arrap parameter
049:             * 
050:             * @param clazz a class for the OriginEntryFull class
051:             * @param columnNames an array of database columns
052:             * @param caseInsensitive whether to do matching
053:             * @return for every valid index in the return value and the array, the value in the array is the db column name, and the value
054:             *         in the list is the java attribute name
055:             * @see org.kuali.module.gl.dao.ReconciliationDao#convertDBColumnNamesToJavaName(java.lang.String[])
056:             */
057:            public List<String> convertDBColumnNamesToJavaName(
058:                    Class<? extends OriginEntryFull> clazz,
059:                    String[] columnNames, boolean caseInsensitive) {
060:                List<String> results = new ArrayList<String>();
061:                ClassDescriptor classDescriptor = getClassDescriptor(clazz);
062:                for (int i = 0; i < columnNames.length; i++) {
063:                    results.add(convertDBColumnNameToJavaName(classDescriptor,
064:                            columnNames[i], caseInsensitive));
065:                }
066:                return results;
067:            }
068:
069:            /**
070:             * Returns the java attribute name corresponding to the column name
071:             * 
072:             * @param classDescriptor the origin entry class
073:             * @param columnName the DB column name
074:             * @param caseInsensitive whether to do case insensitive matching
075:             * @return the java attribute name
076:             */
077:            protected String convertDBColumnNameToJavaName(
078:                    ClassDescriptor classDescriptor, String columnName,
079:                    boolean caseInsensitive) {
080:                FieldDescriptor[] fields = classDescriptor
081:                        .getFieldDescriptions();
082:                for (FieldDescriptor field : fields) {
083:                    if (caseInsensitive
084:                            && field.getColumnName().equalsIgnoreCase(
085:                                    columnName)) {
086:                        return field.getAttributeName();
087:                    }
088:                    if (!caseInsensitive
089:                            && field.getColumnName().equals(columnName)) {
090:                        return field.getAttributeName();
091:                    }
092:                }
093:                return null;
094:            }
095:
096:            /**
097:             * Returns the OJB class descriptor
098:             * 
099:             * @param <E> an origin entry class
100:             * @param persistableClass the class
101:             * @return the class descriptor
102:             */
103:            protected <E extends OriginEntryFull> ClassDescriptor getClassDescriptor(
104:                    Class<E> persistableClass) {
105:                if (persistableClass == null) {
106:                    throw new IllegalArgumentException("invalid (null) object");
107:                }
108:
109:                ClassDescriptor classDescriptor = null;
110:                DescriptorRepository globalRepository = getDescriptorRepository();
111:                try {
112:                    classDescriptor = globalRepository
113:                            .getDescriptorFor(persistableClass);
114:                } catch (ClassNotPersistenceCapableException e) {
115:                    throw new ClassNotPersistableException("class '"
116:                            + persistableClass.getName()
117:                            + "' is not persistable", e);
118:                }
119:
120:                return classDescriptor;
121:            }
122:
123:            /**
124:             * Gets the descriptorRepository attribute.
125:             * 
126:             * @return Returns the descriptorRepository.
127:             */
128:            protected DescriptorRepository getDescriptorRepository() {
129:                return descriptorRepository;
130:            }
131:
132:            /**
133:             * Sets the descriptorRepository attribute value.
134:             * 
135:             * @param descriptorRepository The descriptorRepository to set.
136:             */
137:            public void setDescriptorRepository(
138:                    DescriptorRepository descriptorRepository) {
139:                this.descriptorRepository = descriptorRepository;
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.