Source Code Cross Referenced for DocumentDaoOjb.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » 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.core.dao.ojb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-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.core.dao.ojb;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.HashMap;
021:        import java.util.List;
022:
023:        import org.apache.log4j.Logger;
024:        import org.apache.ojb.broker.query.Criteria;
025:        import org.apache.ojb.broker.query.QueryByCriteria;
026:        import org.apache.ojb.broker.query.QueryFactory;
027:        import org.kuali.RicePropertyConstants;
028:        import org.kuali.core.bo.AdHocRoutePerson;
029:        import org.kuali.core.bo.AdHocRouteWorkgroup;
030:        import org.kuali.core.bo.PersistableBusinessObject;
031:        import org.kuali.core.dao.BusinessObjectDao;
032:        import org.kuali.core.dao.DocumentDao;
033:        import org.kuali.core.document.Document;
034:        import org.kuali.core.util.OjbCollectionAware;
035:        import org.kuali.rice.KNSServiceLocator;
036:        import org.springframework.dao.DataAccessException;
037:
038:        /**
039:         * This class is the OJB implementation of the DocumentDao interface.
040:         */
041:        public class DocumentDaoOjb extends PlatformAwareDaoBaseOjb implements 
042:                DocumentDao, OjbCollectionAware {
043:            private static Logger LOG = Logger.getLogger(DocumentDaoOjb.class);
044:            private BusinessObjectDao businessObjectDao;
045:
046:            public DocumentDaoOjb() {
047:                super ();
048:            }
049:
050:            /*
051:             * (non-Javadoc)
052:             * 
053:             * @see org.kuali.dao.DocumentDao#save(null)
054:             */
055:            public void save(Document document) throws DataAccessException {
056:                Document retrievedDocument = findByDocumentHeaderId(document
057:                        .getClass(), document.getDocumentNumber());
058:                KNSServiceLocator.getOjbCollectionHelper().processCollections(
059:                        this , document, retrievedDocument);
060:                this .getPersistenceBrokerTemplate().store(document);
061:            }
062:
063:            /**
064:             * Retrieve a Document of a specific type with a given document header ID.
065:             * 
066:             * @param clazz
067:             * @param id
068:             * @return Document with given id
069:             */
070:            public Document findByDocumentHeaderId(Class clazz, String id)
071:                    throws DataAccessException {
072:                List idList = new ArrayList();
073:                idList.add(id);
074:
075:                List documentList = findByDocumentHeaderIds(clazz, idList);
076:
077:                Document document = null;
078:                if ((null != documentList) && (documentList.size() > 0)) {
079:                    document = (Document) documentList.get(0);
080:                }
081:
082:                return document;
083:            }
084:
085:            /**
086:             * Retrieve a List of Document instances with the given ids
087:             * 
088:             * @param clazz
089:             * @param idList
090:             * @return List
091:             */
092:            public List findByDocumentHeaderIds(Class clazz, List idList)
093:                    throws DataAccessException {
094:                Criteria criteria = new Criteria();
095:                criteria.addIn(RicePropertyConstants.DOCUMENT_NUMBER, idList);
096:
097:                QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
098:                ArrayList<Document> tempList = new ArrayList(this 
099:                        .getPersistenceBrokerTemplate().getCollectionByQuery(
100:                                query));
101:                for (Document doc : tempList)
102:                    addAdHocs(doc);
103:                return tempList;
104:            }
105:
106:            /**
107:             * Retrieves a collection of documents with type of given Class, and with the passed status code.
108:             * 
109:             * @see org.kuali.core.dao.DocumentDao#findByDocumentHeaderStatusCode(java.lang.Class, java.lang.String)
110:             */
111:            public Collection findByDocumentHeaderStatusCode(Class clazz,
112:                    String statusCode) {
113:                Criteria criteria = new Criteria();
114:                criteria.addEqualTo(RicePropertyConstants.DOCUMENT_HEADER + "."
115:                        + RicePropertyConstants.FINANCIAL_DOCUMENT_STATUS_CODE,
116:                        statusCode);
117:
118:                QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
119:
120:                ArrayList<Document> tempList = new ArrayList(this 
121:                        .getPersistenceBrokerTemplate().getCollectionByQuery(
122:                                query));
123:                for (Document doc : tempList)
124:                    addAdHocs(doc);
125:                return tempList;
126:            }
127:
128:            /**
129:             * 
130:             * Deprecated method. Should use BusinessObjectService.linkAndSave() instead.
131:             * 
132:             */
133:            @Deprecated
134:            public void saveMaintainableBusinessObject(
135:                    PersistableBusinessObject businessObject) {
136:                /*
137:                 * this call is to assure all the object fk values are in sync and the fk fields is set in the main object
138:                 */
139:                KNSServiceLocator.getPersistenceService().linkObjects(
140:                        businessObject);
141:                this .getPersistenceBrokerTemplate().store(businessObject);
142:            }
143:
144:            public Document addAdHocs(Document document) {
145:                /* Instead of reading the doc header to see if doc is in saved status
146:                 * its probably easier and faster to just do this all the time and
147:                 * store a null when appropriate.
148:                 */
149:                List adHocRoutePersons;
150:                List adHocRouteWorkgroups;
151:                HashMap criteriaPerson = new HashMap();
152:                HashMap criteriaWorkgroup = new HashMap();
153:
154:                criteriaPerson.put("documentNumber", document
155:                        .getDocumentNumber());
156:                criteriaPerson.put("type", AdHocRoutePerson.PERSON_TYPE);
157:                adHocRoutePersons = (List) businessObjectDao.findMatching(
158:                        AdHocRoutePerson.class, criteriaPerson);
159:                criteriaWorkgroup.put("documentNumber", document
160:                        .getDocumentNumber());
161:                criteriaWorkgroup.put("type",
162:                        AdHocRouteWorkgroup.WORKGROUP_TYPE);
163:                adHocRouteWorkgroups = (List) businessObjectDao.findMatching(
164:                        AdHocRouteWorkgroup.class, criteriaWorkgroup);
165:                document.setAdHocRoutePersons(adHocRoutePersons);
166:                document.setAdHocRouteWorkgroups(adHocRouteWorkgroups);
167:
168:                return document;
169:            }
170:
171:            public BusinessObjectDao getBusinessObjectDao() {
172:                return businessObjectDao;
173:            }
174:
175:            public void setBusinessObjectDao(BusinessObjectDao businessObjectDao) {
176:                this.businessObjectDao = businessObjectDao;
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.