Source Code Cross Referenced for TaskRepositoryHibernate.java in  » Project-Management » XPlanner-0.7b7 » com » technoetic » xplanner » domain » repository » 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 » Project Management » XPlanner 0.7b7 » com.technoetic.xplanner.domain.repository 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.technoetic.xplanner.domain.repository;
002:
003:        import java.util.Collection;
004:        import java.util.Date;
005:        import java.util.List;
006:
007:        import net.sf.hibernate.Hibernate;
008:        import net.sf.hibernate.HibernateException;
009:        import net.sf.hibernate.type.Type;
010:        import org.apache.commons.collections.CollectionUtils;
011:        import org.apache.commons.collections.Predicate;
012:        import org.springframework.orm.hibernate.HibernateTemplate;
013:
014:        import com.technoetic.xplanner.domain.Task;
015:
016:        /*
017:         * A Hibernate implementation of the TaskRepository interface.
018:         * 
019:         * Implementation is based pretty heavily on (and should 
020:         * eventually supercede) TaskQueryHelper.
021:         * 
022:         * @author James Beard
023:         * @see    com.technoetic.xplanner.db.TaskQueryHelper
024:         */
025:        public class TaskRepositoryHibernate extends HibernateObjectRepository
026:                implements  TaskRepository {
027:            public static final String EMAIL_TO_LEADS_QUERY = "com.technoetic.xplanner.domain.TimeEntryEmailNotificationToProjectSpecificLeads";
028:            public static final String EMAIL_TO_ACCEPTORS_QUERY = "com.technoetic.xplanner.domain.TimeEntryEmailNotificationToAcceptors";
029:
030:            /*
031:             * A implementation of the Predicate interface to filter
032:             * collections of tasks based on whether they are completed
033:             * and/or active.
034:             * 
035:             * @author James Beard
036:             */
037:            private class TaskStatusFilter implements  Predicate {
038:                Boolean isCompleted;
039:                Boolean isActive;
040:
041:                public TaskStatusFilter(Boolean isCompleted, Boolean isActive) {
042:                    this .isCompleted = isCompleted;
043:                    this .isActive = isActive;
044:                }
045:
046:                public boolean evaluate(Object o) {
047:                    final Task task = (Task) o;
048:                    return (isCompleted == null || isCompleted.booleanValue() == task
049:                            .isCompleted())
050:                            && (isActive == null || isActive.booleanValue() == task
051:                                    .getTimeEntries().size() > 0);
052:                }
053:            }
054:
055:            public TaskRepositoryHibernate() throws HibernateException {
056:                super (Task.class);
057:            }
058:
059:            /*
060:             * Returns a collection of tasks in current iterations where personId 
061:             * is the acceptor, and the task has been started.
062:             * 
063:             * @param  personId    the id of the acceptor
064:             * @return             the collection of tasks
065:             */
066:            public Collection getCurrentActiveTasksForPerson(int personId) {
067:                return getCurrentActiveTasks(getCurrentTasksForPerson(personId));
068:            }
069:
070:            /*
071:             * Filters a collection of tasks for those in current iterations
072:             * that have been started.
073:             * 
074:             * Can be used to further filter a cached Collection of all the tasks for
075:             * a particular person.
076:             * 
077:             * @param tasks the collection of tasks
078:             * @return      the filtered collection of tasks
079:             */
080:            public Collection getCurrentActiveTasks(Collection tasks) {
081:                return CollectionUtils.select(tasks, new TaskStatusFilter(
082:                        Boolean.FALSE, Boolean.TRUE));
083:            }
084:
085:            /*
086:             * Returns a collection of tasks in current iterations where personId 
087:             * is the acceptor, and the task hasn't been started yet.
088:             * 
089:             * @param  personId    the id of the acceptor
090:             * @return             the collection of tasks
091:             */
092:            public Collection getCurrentPendingTasksForPerson(int personId) {
093:                return getCurrentPendingTasks(getCurrentTasksForPerson(personId));
094:            }
095:
096:            /*
097:             * Filters a collection of tasks for those in current iterations
098:             * that haven't been started yet.
099:             * 
100:             * Can be used to further filter a cached Collection of all the tasks for
101:             * a particular person. 
102:             * 
103:             * @param tasks the collection of tasks
104:             * @return      the filtered collection of tasks
105:             */
106:            public Collection getCurrentPendingTasks(Collection tasks) {
107:                return CollectionUtils.select(tasks, new TaskStatusFilter(
108:                        Boolean.FALSE, Boolean.FALSE));
109:            }
110:
111:            /*
112:             * Returns a collection of tasks in current iterations where personId 
113:             * is the acceptor, and the task has already been completed.
114:             * 
115:             * @param  personId    the id of the acceptor
116:             * @return             the collection of tasks
117:             */
118:            public Collection getCurrentCompletedTasksForPerson(int personId) {
119:                return getCurrentCompletedTasks(getCurrentTasksForPerson(personId));
120:            }
121:
122:            /*
123:             * Filters a collection of tasks for those in current iterations
124:             * that have already been completed.
125:             * 
126:             * Can be used to further filter a cached Collection of all the tasks for
127:             * a particular person. 
128:             * 
129:             * @param tasks the collection of tasks
130:             * @return      the filtered collection of tasks
131:             */
132:            public Collection getCurrentCompletedTasks(Collection tasks) {
133:                return CollectionUtils.select(tasks, new TaskStatusFilter(
134:                        Boolean.TRUE, null));
135:            }
136:
137:            /*
138:             * Returns a collection of tasks in future iterations where personId 
139:             * is the acceptor, and the task has not been completed.
140:             * 
141:             * @param  personId    the id of the acceptor
142:             * @return             the collection of tasks
143:             */
144:            public Collection getFutureTasksForPerson(int personId) {
145:                return queryTasks("tasks.planned.future", personId);
146:            }
147:
148:            public Collection getTaskAcceptorsEmailNotification(Date date) {
149:                return getHibernateTemplate().findByNamedQuery(
150:                        EMAIL_TO_ACCEPTORS_QUERY, date);
151:            }
152:
153:            public Collection getProjectLeadsEmailNotification(Date date) {
154:                return getHibernateTemplate().findByNamedQuery(
155:                        EMAIL_TO_LEADS_QUERY, date);
156:            }
157:
158:            /*
159:             * Returns a collection of tasks in current iterations where personId 
160:             * is the acceptor.
161:             * 
162:             * @param  personId    the id of the acceptor
163:             * @return             the collection of tasks
164:             */
165:            public Collection getCurrentTasksForPerson(int personId) {
166:                Collection currentTasks = queryTasks("tasks.current.accepted",
167:                        personId);
168:                currentTasks
169:                        .addAll(queryTasks("tasks.current.worked", personId));
170:
171:                return currentTasks;
172:            }
173:
174:            private List queryTasks(String queryName, int personId) {
175:                return getHibernateTemplate().findByNamedQueryAndNamedParam(
176:                        queryName, new String[] { "now", "personId" },
177:                        new Object[] { new Date(), new Integer(personId) },
178:                        new Type[] { Hibernate.DATE, Hibernate.INTEGER });
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.