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


001:        /*
002:         * Copyright 2005-2006 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.actionrequests.dao;
018:
019:        import java.sql.Timestamp;
020:        import java.util.Collection;
021:        import java.util.Collections;
022:        import java.util.List;
023:
024:        import org.apache.ojb.broker.query.Criteria;
025:        import org.apache.ojb.broker.query.QueryByCriteria;
026:        import org.springmodules.orm.ojb.PersistenceBrokerTemplate;
027:        import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
028:
029:        import edu.iu.uis.eden.EdenConstants;
030:        import edu.iu.uis.eden.actionrequests.ActionRequestValue;
031:        import edu.iu.uis.eden.workgroup.Workgroup;
032:
033:        /**
034:         * OJB implementation of the {@link ActionRequestDAO}.
035:         *
036:         * @author ewestfal
037:         * @author rkirkend
038:         */
039:        public class ActionRequestDAOOjbImpl extends
040:                PersistenceBrokerDaoSupport implements  ActionRequestDAO {
041:
042:            public ActionRequestValue getActionRequestByActionRequestId(
043:                    Long actionRequestId) {
044:                Criteria crit = new Criteria();
045:                crit.addEqualTo("actionRequestId", actionRequestId);
046:                return (ActionRequestValue) this .getPersistenceBrokerTemplate()
047:                        .getObjectByQuery(
048:                                new QueryByCriteria(ActionRequestValue.class,
049:                                        crit));
050:            }
051:
052:            public void saveActionRequest(ActionRequestValue actionRequest) {
053:                if (actionRequest.getActionRequestId() == null) {
054:                    loadDefaultValues(actionRequest);
055:                }
056:                this .getPersistenceBrokerTemplate().store(actionRequest);
057:            }
058:
059:            public List findPendingByResponsibilityIds(
060:                    Collection responsibilityIds) {
061:                if (responsibilityIds == null || responsibilityIds.size() == 0)
062:                    return Collections.EMPTY_LIST;
063:                Criteria crit = new Criteria();
064:                Criteria statusCriteria = new Criteria();
065:                Criteria activatedCriteria = new Criteria();
066:                activatedCriteria.addEqualTo("status",
067:                        EdenConstants.ACTION_REQUEST_ACTIVATED);
068:
069:                Criteria initializedCriteria = new Criteria();
070:                initializedCriteria.addEqualTo("status",
071:                        EdenConstants.ACTION_REQUEST_INITIALIZED);
072:
073:                statusCriteria.addOrCriteria(activatedCriteria);
074:                statusCriteria.addOrCriteria(initializedCriteria);
075:                crit.addAndCriteria(statusCriteria);
076:                crit.addIn("responsibilityId", responsibilityIds);
077:                return (List) this .getPersistenceBrokerTemplate()
078:                        .getCollectionByQuery(
079:                                new QueryByCriteria(ActionRequestValue.class,
080:                                        crit));
081:            }
082:
083:            public List findPendingByActionRequestedAndDocId(
084:                    String actionRequestedCd, Long routeHeaderId) {
085:                Criteria crit = new Criteria();
086:                crit.addEqualTo("actionRequested", actionRequestedCd);
087:                crit.addEqualTo("routeHeaderId", routeHeaderId);
088:                crit.addEqualTo("currentIndicator", Boolean.TRUE);
089:                crit.addAndCriteria(getPendingCriteria());
090:                return (List) this .getPersistenceBrokerTemplate()
091:                        .getCollectionByQuery(
092:                                new QueryByCriteria(ActionRequestValue.class,
093:                                        crit));
094:            }
095:
096:            public List findByStatusAndDocId(String statusCd, Long routeHeaderId) {
097:                Criteria crit = new Criteria();
098:                crit.addEqualTo("status", statusCd);
099:                crit.addEqualTo("routeHeaderId", routeHeaderId);
100:                crit.addEqualTo("currentIndicator", new Boolean(true));
101:
102:                return (List) this .getPersistenceBrokerTemplate()
103:                        .getCollectionByQuery(
104:                                new QueryByCriteria(ActionRequestValue.class,
105:                                        crit));
106:            }
107:
108:            private void loadDefaultValues(ActionRequestValue actionRequest) {
109:                checkNull(actionRequest.getActionRequested(),
110:                        "action requested");
111:                checkNull(actionRequest.getResponsibilityId(),
112:                        "responsibility ID");
113:                checkNull(actionRequest.getRouteLevel(), "route level");
114:                checkNull(actionRequest.getDocVersion(), "doc version");
115:                if (actionRequest.getIgnorePrevAction() == null) {
116:                    actionRequest.setIgnorePrevAction(Boolean.FALSE);
117:                }
118:                if (actionRequest.getStatus() == null) {
119:                    actionRequest
120:                            .setStatus(EdenConstants.ACTION_REQUEST_INITIALIZED);
121:                }
122:                if (actionRequest.getPriority() == null) {
123:                    actionRequest.setPriority(new Integer(
124:                            EdenConstants.ACTION_REQUEST_DEFAULT_PRIORITY));
125:                }
126:                if (actionRequest.getCurrentIndicator() == null) {
127:                    actionRequest.setCurrentIndicator(new Boolean(true));
128:                }
129:                actionRequest.setCreateDate(new Timestamp(System
130:                        .currentTimeMillis()));
131:            }
132:
133:            //TODO Runtime might not be the right thing to do here...
134:            private void checkNull(Object value, String valueName)
135:                    throws RuntimeException {
136:                if (value == null) {
137:                    throw new RuntimeException("Null value for " + valueName);
138:                }
139:            }
140:
141:            public List findPendingRootRequestsByDocIdAtRouteLevel(
142:                    Long routeHeaderId, Integer routeLevel) {
143:                Criteria crit = new Criteria();
144:                crit.addEqualTo("routeLevel", routeLevel);
145:                crit.addNotEqualTo("status",
146:                        EdenConstants.ACTION_REQUEST_DONE_STATE);
147:                crit.addEqualTo("routeHeaderId", routeHeaderId);
148:                crit.addEqualTo("currentIndicator", Boolean.TRUE);
149:                crit.addIsNull("parentActionRequest");
150:                return (List) this .getPersistenceBrokerTemplate()
151:                        .getCollectionByQuery(
152:                                new QueryByCriteria(ActionRequestValue.class,
153:                                        crit));
154:            }
155:
156:            public List findPendingByDocIdAtOrBelowRouteLevel(
157:                    Long routeHeaderId, Integer routeLevel) {
158:                Criteria crit = new Criteria();
159:                crit.addLessOrEqualThan("routeLevel", routeLevel);
160:                crit.addNotEqualTo("status",
161:                        EdenConstants.ACTION_REQUEST_DONE_STATE);
162:                crit.addEqualTo("routeHeaderId", routeHeaderId);
163:                crit.addEqualTo("currentIndicator", new Boolean(true));
164:                return (List) this .getPersistenceBrokerTemplate()
165:                        .getCollectionByQuery(
166:                                new QueryByCriteria(ActionRequestValue.class,
167:                                        crit));
168:            }
169:
170:            public List findPendingRootRequestsByDocIdAtOrBelowRouteLevel(
171:                    Long routeHeaderId, Integer routeLevel) {
172:                Criteria crit = new Criteria();
173:                crit.addLessOrEqualThan("routeLevel", routeLevel);
174:                crit.addNotEqualTo("status",
175:                        EdenConstants.ACTION_REQUEST_DONE_STATE);
176:                crit.addEqualTo("routeHeaderId", routeHeaderId);
177:                crit.addEqualTo("currentIndicator", new Boolean(true));
178:                crit.addIsNull("parentActionRequest");
179:                return (List) this .getPersistenceBrokerTemplate()
180:                        .getCollectionByQuery(
181:                                new QueryByCriteria(ActionRequestValue.class,
182:                                        crit));
183:            }
184:
185:            public void delete(Long actionRequestId) {
186:                Criteria crit = new Criteria();
187:                crit.addEqualTo("actionRequestId", actionRequestId);
188:                this .getPersistenceBrokerTemplate().deleteByQuery(
189:                        new QueryByCriteria(ActionRequestValue.class, crit));
190:            }
191:
192:            public List findAllPendingByDocId(Long routeHeaderId) {
193:                Criteria initializedStatCriteria = new Criteria();
194:                initializedStatCriteria.addEqualTo("status",
195:                        EdenConstants.ACTION_REQUEST_INITIALIZED);
196:
197:                Criteria activatedStatCriteria = new Criteria();
198:                activatedStatCriteria.addEqualTo("status",
199:                        EdenConstants.ACTION_REQUEST_ACTIVATED);
200:
201:                Criteria statusCriteria = new Criteria();
202:                statusCriteria.addOrCriteria(initializedStatCriteria);
203:                statusCriteria.addOrCriteria(activatedStatCriteria);
204:
205:                Criteria crit = new Criteria();
206:                crit.addEqualTo("routeHeaderId", routeHeaderId);
207:                crit.addEqualTo("currentIndicator", new Boolean(true));
208:                crit.addAndCriteria(statusCriteria);
209:
210:                return (List) this .getPersistenceBrokerTemplate()
211:                        .getCollectionByQuery(
212:                                new QueryByCriteria(ActionRequestValue.class,
213:                                        crit));
214:            }
215:
216:            public List findAllByDocId(Long routeHeaderId) {
217:                Criteria crit = new Criteria();
218:                crit.addEqualTo("routeHeaderId", routeHeaderId);
219:                crit.addEqualTo("currentIndicator", new Boolean(true));
220:                return (List) this .getPersistenceBrokerTemplate()
221:                        .getCollectionByQuery(
222:                                new QueryByCriteria(ActionRequestValue.class,
223:                                        crit));
224:            }
225:
226:            public List findAllRootByDocId(Long routeHeaderId) {
227:                Criteria crit = new Criteria();
228:                crit.addEqualTo("routeHeaderId", routeHeaderId);
229:                crit.addEqualTo("currentIndicator", new Boolean(true));
230:                crit.addIsNull("parentActionRequest");
231:                return (List) this .getPersistenceBrokerTemplate()
232:                        .getCollectionByQuery(
233:                                new QueryByCriteria(ActionRequestValue.class,
234:                                        crit));
235:            }
236:
237:            public List findByRouteHeaderIdIgnoreCurrentInd(Long routeHeaderId) {
238:                Criteria crit = new Criteria();
239:                crit.addEqualTo("routeHeaderId", routeHeaderId);
240:                return (List) this .getPersistenceBrokerTemplate()
241:                        .getCollectionByQuery(
242:                                new QueryByCriteria(ActionRequestValue.class,
243:                                        crit));
244:            }
245:
246:            public List findActivatedByWorkgroup(Workgroup workgroup) {
247:                Criteria statusCriteria = new Criteria();
248:                statusCriteria.addEqualTo("status",
249:                        EdenConstants.ACTION_REQUEST_ACTIVATED);
250:                Criteria crit = new Criteria();
251:                crit.addEqualTo("workgroupId", workgroup.getWorkflowGroupId()
252:                        .getGroupId());
253:                crit.addEqualTo("currentIndicator", new Boolean(true));
254:                crit.addAndCriteria(statusCriteria);
255:
256:                return (List) this .getPersistenceBrokerTemplate()
257:                        .getCollectionByQuery(
258:                                new QueryByCriteria(ActionRequestValue.class,
259:                                        crit));
260:            }
261:
262:            private Criteria getPendingCriteria() {
263:                Criteria pendingCriteria = new Criteria();
264:                Criteria activatedCriteria = new Criteria();
265:                activatedCriteria.addEqualTo("status",
266:                        EdenConstants.ACTION_REQUEST_ACTIVATED);
267:                Criteria initializedCriteria = new Criteria();
268:                initializedCriteria.addEqualTo("status",
269:                        EdenConstants.ACTION_REQUEST_INITIALIZED);
270:                pendingCriteria.addOrCriteria(activatedCriteria);
271:                pendingCriteria.addOrCriteria(initializedCriteria);
272:                return pendingCriteria;
273:            }
274:
275:            public void deleteByRouteHeaderId(Long routeHeaderId) {
276:                Criteria crit = new Criteria();
277:                crit.addEqualTo("routeHeaderId", routeHeaderId);
278:                this .getPersistenceBrokerTemplate().deleteByQuery(
279:                        new QueryByCriteria(ActionRequestValue.class, crit));
280:            }
281:
282:            public List findPendingRootRequestsByDocumentType(
283:                    Long documentTypeId) {
284:                Criteria crit = new Criteria();
285:                crit.addEqualTo("routeHeader.documentTypeId", documentTypeId);
286:                crit.addAndCriteria(getPendingCriteria());
287:                crit.addEqualTo("currentIndicator", Boolean.TRUE);
288:                crit.addIsNull("parentActionRequest");
289:                return (List) this .getPersistenceBrokerTemplate()
290:                        .getCollectionByQuery(
291:                                new QueryByCriteria(ActionRequestValue.class,
292:                                        crit));
293:            }
294:
295:            public List findPendingRootRequestsByDocIdAtRouteNode(
296:                    Long routeHeaderId, Long nodeInstanceId) {
297:                Criteria crit = new Criteria();
298:                crit.addEqualTo("routeHeaderId", routeHeaderId);
299:                crit.addAndCriteria(getPendingCriteria());
300:                crit.addEqualTo("currentIndicator", Boolean.TRUE);
301:                crit.addIsNull("parentActionRequest");
302:                crit.addEqualTo("nodeInstance.routeNodeInstanceId",
303:                        nodeInstanceId);
304:                return (List) this .getPersistenceBrokerTemplate()
305:                        .getCollectionByQuery(
306:                                new QueryByCriteria(ActionRequestValue.class,
307:                                        crit));
308:            }
309:
310:            public List findRootRequestsByDocIdAtRouteNode(Long documentId,
311:                    Long nodeInstanceId) {
312:                Criteria crit = new Criteria();
313:                crit.addEqualTo("routeHeaderId", documentId);
314:                crit.addEqualTo("currentIndicator", Boolean.TRUE);
315:                crit.addIsNull("parentActionRequest");
316:                crit.addEqualTo("nodeInstance.routeNodeInstanceId",
317:                        nodeInstanceId);
318:                return (List) this .getPersistenceBrokerTemplate()
319:                        .getCollectionByQuery(
320:                                new QueryByCriteria(ActionRequestValue.class,
321:                                        crit));
322:            }
323:
324:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.