Source Code Cross Referenced for QuickLinksDAOOjbImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » quicklinks » dao » 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 » edu.iu.uis.eden.quicklinks.dao 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.quicklinks.dao;
018:
019:        import java.sql.Connection;
020:        import java.sql.PreparedStatement;
021:        import java.sql.ResultSet;
022:        import java.sql.SQLException;
023:        import java.util.ArrayList;
024:        import java.util.Collections;
025:        import java.util.List;
026:        import java.util.StringTokenizer;
027:
028:        import org.apache.ojb.broker.PersistenceBroker;
029:        import org.springmodules.orm.ojb.PersistenceBrokerCallback;
030:        import org.springmodules.orm.ojb.PersistenceBrokerTemplate;
031:        import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
032:
033:        import edu.iu.uis.eden.EdenConstants;
034:        import edu.iu.uis.eden.KEWServiceLocator;
035:        import edu.iu.uis.eden.docsearch.DocumentSearchService;
036:        import edu.iu.uis.eden.doctype.DocumentType;
037:        import edu.iu.uis.eden.doctype.DocumentTypePolicy;
038:        import edu.iu.uis.eden.doctype.DocumentTypeService;
039:        import edu.iu.uis.eden.exception.WorkflowRuntimeException;
040:        import edu.iu.uis.eden.quicklinks.ActionListStats;
041:        import edu.iu.uis.eden.quicklinks.InitiatedDocumentType;
042:        import edu.iu.uis.eden.quicklinks.WatchedDocument;
043:        import edu.iu.uis.eden.user.WorkflowUser;
044:        import edu.iu.uis.eden.util.Utilities;
045:
046:        public class QuickLinksDAOOjbImpl extends PersistenceBrokerDaoSupport
047:                implements  QuickLinksDAO {
048:
049:            public List getActionListStats(final WorkflowUser workflowUser) {
050:                return (List) this .getPersistenceBrokerTemplate().execute(
051:                        new PersistenceBrokerCallback() {
052:                            public Object doInPersistenceBroker(
053:                                    PersistenceBroker broker) {
054:                                PreparedStatement selectActionItems = null;
055:                                PreparedStatement selectDocTypeLabel = null;
056:                                ResultSet selectedActionItems = null;
057:                                ResultSet selectedDocTypeLabel = null;
058:                                List docTypes = new ArrayList();
059:                                try {
060:                                    Connection connection = broker
061:                                            .serviceConnectionManager()
062:                                            .getConnection();
063:                                    selectActionItems = connection
064:                                            .prepareStatement("select DOC_TYP_NM, COUNT(*) from EN_ACTN_ITM_T where ACTN_ITM_PRSN_EN_ID = ? "
065:                                                    + "and (dlgn_typ is null or dlgn_typ != '"
066:                                                    + EdenConstants.DELEGATION_SECONDARY
067:                                                    + "') group by DOC_TYP_NM");
068:                                    selectDocTypeLabel = connection
069:                                            .prepareStatement("select DOC_TYP_LBL_TXT from EN_DOC_TYP_T WHERE DOC_TYP_NM = ? and DOC_TYP_CUR_IND = 1");
070:                                    selectActionItems.setString(1, workflowUser
071:                                            .getWorkflowUserId()
072:                                            .getWorkflowId());
073:                                    selectedActionItems = selectActionItems
074:                                            .executeQuery();
075:                                    while (selectedActionItems.next()) {
076:                                        String docTypeName = selectedActionItems
077:                                                .getString(1);
078:                                        int count = selectedActionItems
079:                                                .getInt(2);
080:                                        selectDocTypeLabel.setString(1,
081:                                                docTypeName);
082:                                        selectedDocTypeLabel = selectDocTypeLabel
083:                                                .executeQuery();
084:                                        if (selectedDocTypeLabel.next()) {
085:                                            docTypes.add(new ActionListStats(
086:                                                    docTypeName,
087:                                                    selectedDocTypeLabel
088:                                                            .getString(1),
089:                                                    count));
090:                                        }
091:                                    }
092:                                    Collections.sort(docTypes);
093:                                    return docTypes;
094:                                } catch (Exception e) {
095:                                    throw new WorkflowRuntimeException(
096:                                            "Error getting action list stats for user: "
097:                                                    + workflowUser
098:                                                            .getAuthenticationUserId()
099:                                                            .getAuthenticationId(),
100:                                            e);
101:                                } finally {
102:                                    if (selectActionItems != null) {
103:                                        try {
104:                                            selectActionItems.close();
105:                                        } catch (SQLException e) {
106:                                        }
107:                                    }
108:
109:                                    if (selectDocTypeLabel != null) {
110:                                        try {
111:                                            selectDocTypeLabel.close();
112:                                        } catch (SQLException e) {
113:                                        }
114:                                    }
115:
116:                                    if (selectedActionItems != null) {
117:                                        try {
118:                                            selectedActionItems.close();
119:                                        } catch (SQLException e) {
120:                                        }
121:                                    }
122:
123:                                    if (selectedDocTypeLabel != null) {
124:                                        try {
125:                                            selectedDocTypeLabel.close();
126:                                        } catch (SQLException e) {
127:                                        }
128:                                    }
129:
130:                                }
131:                            }
132:                        });
133:            }
134:
135:            public List getInitiatedDocumentTypesList(
136:                    final WorkflowUser workflowUser) {
137:                return (List) this .getPersistenceBrokerTemplate().execute(
138:                        new PersistenceBrokerCallback() {
139:
140:                            public Object doInPersistenceBroker(
141:                                    PersistenceBroker broker) {
142:                                PreparedStatement selectDistinctDocumentTypes = null;
143:                                ResultSet selectedDistinctDocumentTypes = null;
144:                                List documentTypesByName = new ArrayList();
145:                                try {
146:                                    Connection connection = broker
147:                                            .serviceConnectionManager()
148:                                            .getConnection();
149:                                    //                  select the doc type only if the SUPPORTS_QUICK_INITIATE policy is NULL or true
150:                                    String sql = "select distinct B.DOC_TYP_NM, B.DOC_TYP_LBL_TXT from EN_DOC_HDR_T A, EN_DOC_TYP_T B "
151:                                            + "where A.DOC_INITR_PRSN_EN_ID = ? and A.DOC_TYP_ID = B.DOC_TYP_ID and "
152:                                            + "B.DOC_TYP_ACTV_IND = 1 and B.DOC_TYP_CUR_IND = 1 "
153:                                            + "order by upper(B.DOC_TYP_LBL_TXT)";
154:                                    selectDistinctDocumentTypes = connection
155:                                            .prepareStatement(sql);
156:                                    selectDistinctDocumentTypes.setString(1,
157:                                            workflowUser.getWorkflowUserId()
158:                                                    .getWorkflowId());
159:                                    selectedDistinctDocumentTypes = selectDistinctDocumentTypes
160:                                            .executeQuery();
161:                                    String documentNames = Utilities
162:                                            .getApplicationConstant(
163:                                                    EdenConstants.QUICK_LINKS_RESTRICT_DOCUMENT_TYPES)
164:                                            .trim();
165:                                    if (documentNames == null) {
166:                                        documentNames = "";
167:                                    }
168:                                    List docTypesToRestrict = new ArrayList();
169:                                    StringTokenizer st = new StringTokenizer(
170:                                            documentNames, ",");
171:                                    while (st.hasMoreTokens()) {
172:                                        docTypesToRestrict.add(st.nextToken());
173:                                    }
174:                                    while (selectedDistinctDocumentTypes.next()) {
175:                                        String docTypeName = selectedDistinctDocumentTypes
176:                                                .getString(1);
177:                                        String docTypeTopParent = "";
178:                                        int firstPeriod = docTypeName
179:                                                .indexOf(".");
180:                                        if (firstPeriod == -1) {
181:                                            docTypeTopParent = docTypeName
182:                                                    .substring(0);
183:                                        } else {
184:                                            docTypeTopParent = docTypeName
185:                                                    .substring(0, firstPeriod);
186:                                        }
187:                                        if (!docTypesToRestrict
188:                                                .contains(docTypeTopParent)) {
189:                                            // the document types should be cached so this should be pretty quick
190:                                            DocumentType docType = KEWServiceLocator
191:                                                    .getDocumentTypeService()
192:                                                    .findByName(docTypeName);
193:                                            DocumentTypePolicy quickInitiatePolicy = docType
194:                                                    .getSupportsQuickInitiatePolicy();
195:                                            if (quickInitiatePolicy
196:                                                    .getPolicyValue()
197:                                                    .booleanValue()) {
198:                                                documentTypesByName
199:                                                        .add(new InitiatedDocumentType(
200:                                                                docTypeName,
201:                                                                selectedDistinctDocumentTypes
202:                                                                        .getString(2)));
203:                                            }
204:                                        }
205:                                    }
206:                                    return documentTypesByName;
207:                                } catch (Exception e) {
208:                                    throw new WorkflowRuntimeException(
209:                                            "Error getting initiated document types for user: "
210:                                                    + workflowUser
211:                                                            .getAuthenticationUserId()
212:                                                            .getAuthenticationId(),
213:                                            e);
214:                                } finally {
215:                                    if (selectDistinctDocumentTypes != null) {
216:                                        try {
217:                                            selectDistinctDocumentTypes.close();
218:                                        } catch (SQLException e) {
219:                                        }
220:                                    }
221:                                    if (selectedDistinctDocumentTypes != null) {
222:                                        try {
223:                                            selectedDistinctDocumentTypes
224:                                                    .close();
225:                                        } catch (SQLException e) {
226:                                        }
227:                                    }
228:
229:                                }
230:
231:                            }
232:                        });
233:            }
234:
235:            public List getNamedSearches(WorkflowUser workflowUser) {
236:                return getDocumentSearchService()
237:                        .getNamedSearches(workflowUser);
238:            }
239:
240:            public List getRecentSearches(WorkflowUser workflowUser) {
241:                return getDocumentSearchService().getMostRecentSearches(
242:                        workflowUser);
243:            }
244:
245:            public List getWatchedDocuments(final WorkflowUser workflowUser) {
246:                return (List) this .getPersistenceBrokerTemplate().execute(
247:                        new PersistenceBrokerCallback() {
248:                            public Object doInPersistenceBroker(
249:                                    PersistenceBroker broker) {
250:                                List watchedDocuments = new ArrayList();
251:                                PreparedStatement selectWatchedDocuments = null;
252:                                ResultSet selectedWatchedDocuments = null;
253:                                try {
254:                                    Connection connection = broker
255:                                            .serviceConnectionManager()
256:                                            .getConnection();
257:                                    selectWatchedDocuments = connection
258:                                            .prepareStatement("select DOC_HDR_ID, DOC_RTE_STAT_CD, DOC_TTL, DOC_CRTE_DT from EN_DOC_HDR_T where DOC_INITR_PRSN_EN_ID = ? and DOC_RTE_STAT_CD in ('"
259:                                                    + EdenConstants.ROUTE_HEADER_ENROUTE_CD
260:                                                    + "','"
261:                                                    + EdenConstants.ROUTE_HEADER_EXCEPTION_CD
262:                                                    + "') order by DOC_CRTE_DT desc");
263:                                    selectWatchedDocuments.setString(1,
264:                                            workflowUser.getWorkflowUserId()
265:                                                    .getWorkflowId());
266:                                    selectedWatchedDocuments = selectWatchedDocuments
267:                                            .executeQuery();
268:                                    while (selectedWatchedDocuments.next()) {
269:                                        watchedDocuments
270:                                                .add(new WatchedDocument(
271:                                                        selectedWatchedDocuments
272:                                                                .getString(1),
273:                                                        (String) EdenConstants.DOCUMENT_STATUSES
274:                                                                .get(selectedWatchedDocuments
275:                                                                        .getString(2)),
276:                                                        selectedWatchedDocuments
277:                                                                .getString(3)));
278:                                    }
279:                                    return watchedDocuments;
280:                                } catch (Exception e) {
281:                                    throw new WorkflowRuntimeException(
282:                                            "Error getting initiated document types for user: "
283:                                                    + workflowUser
284:                                                            .getAuthenticationUserId()
285:                                                            .getAuthenticationId(),
286:                                            e);
287:                                } finally {
288:                                    if (selectWatchedDocuments != null) {
289:                                        try {
290:                                            selectWatchedDocuments.close();
291:                                        } catch (SQLException e) {
292:                                        }
293:                                    }
294:                                    if (selectedWatchedDocuments != null) {
295:                                        try {
296:                                            selectedWatchedDocuments.close();
297:                                        } catch (SQLException e) {
298:                                        }
299:                                    }
300:
301:                                }
302:                            }
303:                        });
304:            }
305:
306:            public DocumentTypeService getDocumentTypeService() {
307:                return ((DocumentTypeService) KEWServiceLocator
308:                        .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE));
309:            }
310:
311:            public DocumentSearchService getDocumentSearchService() {
312:                return ((DocumentSearchService) KEWServiceLocator
313:                        .getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE));
314:            }
315:
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.