Source Code Cross Referenced for KualiCodeDaoOjb.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » kfs » 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.kfs.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.kfs.dao.ojb;
017:
018:        import java.util.Collection;
019:        import java.util.HashMap;
020:        import java.util.Map;
021:
022:        import org.apache.ojb.broker.query.Criteria;
023:        import org.apache.ojb.broker.query.QueryFactory;
024:        import org.kuali.core.bo.KualiCode;
025:        import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
026:        import org.kuali.kfs.KFSConstants;
027:        import org.kuali.kfs.dao.KualiCodeDao;
028:        import org.kuali.module.cg.bo.AgencyType;
029:        import org.kuali.module.chart.bo.FundGroup;
030:        import org.kuali.module.chart.bo.KualiSystemCode;
031:        import org.kuali.module.chart.bo.ObjSubTyp;
032:        import org.kuali.module.chart.bo.ObjectCode;
033:        import org.kuali.module.chart.bo.ObjectType;
034:        import org.kuali.module.chart.bo.ProjectCode;
035:        import org.kuali.module.chart.bo.RestrictedStatus;
036:        import org.kuali.module.chart.bo.codes.BalanceTyp;
037:        import org.kuali.module.chart.bo.codes.BudgetAggregationCode;
038:        import org.kuali.module.chart.bo.codes.FederalFundedCode;
039:        import org.kuali.module.chart.bo.codes.MandatoryTransferEliminationCode;
040:        import org.kuali.module.financial.bo.PaymentReasonCode;
041:        import org.kuali.module.gl.bo.OriginEntrySource;
042:        import org.kuali.module.kra.budget.bo.NonpersonnelSubCategory;
043:        import org.springframework.dao.DataAccessException;
044:
045:        /**
046:         * This class is the OJB implementation of the KualiCodeDao interface.
047:         */
048:
049:        public class KualiCodeDaoOjb extends PlatformAwareDaoBaseOjb implements 
050:                KualiCodeDao {
051:
052:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
053:                    .getLogger(KualiCodeDaoOjb.class);
054:
055:            private static Map codeColumns = new HashMap();
056:            static {
057:                codeColumns.put(AgencyType.class, "code");
058:                codeColumns.put(BalanceTyp.class, "code");
059:                codeColumns.put(BudgetAggregationCode.class, "code");
060:                codeColumns.put(PaymentReasonCode.class, "code");
061:                codeColumns.put(FederalFundedCode.class, "code");
062:                codeColumns.put(FundGroup.class, "code");
063:                codeColumns.put(MandatoryTransferEliminationCode.class, "code");
064:                codeColumns.put(NonpersonnelSubCategory.class, "code");
065:                codeColumns.put(ObjectCode.class, "financialObjectCode");
066:                codeColumns.put(ObjectType.class, "code");
067:                codeColumns.put(ObjSubTyp.class, "code");
068:                codeColumns.put(OriginEntrySource.class, "code");
069:                codeColumns.put(ProjectCode.class, "code");
070:                codeColumns.put(RestrictedStatus.class,
071:                        "accountRestrictedStatusCode");
072:
073:                // can't add entry for CashDetailTypeCode since the table doesn't yet exist
074:            }
075:
076:            private static Map nameColumns = new HashMap();
077:            static {
078:                nameColumns.put(AgencyType.class, "name");
079:                nameColumns.put(BalanceTyp.class, "name");
080:                nameColumns.put(BudgetAggregationCode.class, "name");
081:                nameColumns.put(PaymentReasonCode.class, "name");
082:                nameColumns.put(FederalFundedCode.class, "name");
083:                nameColumns.put(FundGroup.class, "name");
084:                nameColumns.put(MandatoryTransferEliminationCode.class, "name");
085:                nameColumns.put(NonpersonnelSubCategory.class, "name");
086:                nameColumns.put(ObjectCode.class, "financialObjectCodeName");
087:                nameColumns.put(ObjectType.class, "name");
088:                nameColumns.put(ObjSubTyp.class, "name");
089:                nameColumns.put(OriginEntrySource.class, "name");
090:                nameColumns.put(ProjectCode.class, "name");
091:                nameColumns.put(RestrictedStatus.class,
092:                        "accountRestrictedStatusName");
093:
094:                // can't add entry for CashDetailTypeCode since the table doesn't yet exist
095:            }
096:
097:            /**
098:             * @param className - the name of the object being used, either KualiCodeBase or a subclass
099:             * @param code - code to search for
100:             * @return KualiCodeBase Retrieves an KualiCodeBase object by a given code.
101:             */
102:            public KualiCode getByCode(Class queryClass, String code) {
103:                Criteria criteria = getCriteriaForGivenClass(codeColumns,
104:                        queryClass, code);
105:                if (KualiSystemCode.class.isAssignableFrom(queryClass)) {
106:                    criteria.addEqualTo("CLASS_NAME", queryClass.getName());
107:                    // queryClass = KualiSystemCode.class;
108:                }
109:
110:                return (KualiCode) getPersistenceBrokerTemplate()
111:                        .getObjectByQuery(
112:                                QueryFactory.newQuery(queryClass, criteria));
113:            }
114:
115:            private Criteria getCriteriaForGivenClass(Map map,
116:                    Class queryClass, String value) {
117:                Criteria criteria = new Criteria();
118:                String column = (String) map.get(queryClass);
119:                if (column == null) {
120:                    System.err.println("Need to add logic for "
121:                            + queryClass.getName());
122:                    throw new RuntimeException("Need to add logic for "
123:                            + queryClass.getName());
124:                }
125:                criteria.addEqualTo(column, value);
126:                return criteria;
127:            }
128:
129:            public KualiCode getSystemCode(Class clazz, String code) {
130:                Criteria criteria = new Criteria();
131:                criteria.addEqualTo("CODE", code);
132:                criteria.addEqualTo("CLASS_NAME", clazz.getName());
133:
134:                return (KualiCode) getPersistenceBrokerTemplate()
135:                        .getObjectByQuery(
136:                                QueryFactory.newQuery(clazz, criteria));
137:            }
138:
139:            /**
140:             * @param className - the name of the object being used, either KualiCodeBase or a subclass
141:             * @param name - name to search for
142:             * @return KualiCodeBase Retrieves an KualiCodeBase object by a given exact name.
143:             */
144:            public KualiCode getByName(Class queryClass, String name) {
145:                Criteria criteria = getCriteriaForGivenClass(nameColumns,
146:                        queryClass, name);
147:                if (KualiSystemCode.class.isAssignableFrom(queryClass)) {
148:                    criteria.addEqualTo("className", queryClass.getName());
149:                    queryClass = KualiSystemCode.class;
150:                }
151:
152:                return (KualiCode) getPersistenceBrokerTemplate()
153:                        .getObjectByQuery(
154:                                QueryFactory.newQuery(queryClass, criteria));
155:            }
156:
157:            /**
158:             * @param kualiCode Pass the method a populated KualiCodeBase object, and it will be saved.
159:             */
160:            public void save(KualiCode kualiCode) throws DataAccessException {
161:                getPersistenceBrokerTemplate().store(kualiCode);
162:            }
163:
164:            /**
165:             * Deletes the object-record passed in.
166:             * 
167:             * @param kualiCode
168:             * @throws DataAccessException
169:             */
170:            public void delete(KualiCode kualiCode) {
171:                // try to delete the retrieved object
172:                getPersistenceBrokerTemplate().delete(kualiCode);
173:            }
174:
175:            /**
176:             * @see org.kuali.core.dao.KualiCodeDao#getAllActive(java.lang.Class)
177:             */
178:            public Collection getAllActive(Class queryClass) {
179:                Criteria criteria = new Criteria();
180:                criteria.addEqualTo("FIN_OBJ_ACTIVE_CD",
181:                        KFSConstants.ACTIVE_INDICATOR);
182:                if (KualiSystemCode.class.isAssignableFrom(queryClass)) {
183:                    criteria.addEqualTo("className", queryClass.getName());
184:                    queryClass = KualiSystemCode.class;
185:                }
186:
187:                return getPersistenceBrokerTemplate().getCollectionByQuery(
188:                        QueryFactory.newQuery(queryClass, criteria));
189:            }
190:
191:            /**
192:             * @see org.kuali.core.dao.KualiCodeDao#getAll(java.lang.Class)
193:             */
194:            public Collection getAll(Class queryClass) {
195:                Criteria criteria = new Criteria();
196:                if (KualiSystemCode.class.isAssignableFrom(queryClass)) {
197:                    criteria.addEqualTo("className", queryClass.getName());
198:                    // queryClass = KualiSystemCode.class;
199:                }
200:
201:                // This previously was passing a NULL into the criteria paramter, for no
202:                // apparent reason I could see. The result was that it was ignoring class
203:                // and returning all codes, which is definitely not what we want, and
204:                // definitely not what the interface JavaDocs said. This was fixed.
205:                return getPersistenceBrokerTemplate().getCollectionByQuery(
206:                        QueryFactory.newQuery(queryClass, criteria));
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.