Source Code Cross Referenced for TaskListModel.java in  » Portal » Open-Portal » com » sun » portal » app » sharedtasks » faces » models » 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 » Portal » Open Portal » com.sun.portal.app.sharedtasks.faces.models 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.app.sharedtasks.faces.models;
002:
003:        import com.sun.comclient.calendar.CalendarComponent;
004:        import com.sun.comclient.calendar.CalendarException;
005:        import com.sun.comclient.calendar.DateTime;
006:        import com.sun.comclient.calendar.ICalendar;
007:        import com.sun.comclient.calendar.OperationNotSupportedException;
008:        import com.sun.comclient.calendar.VTodo;
009:        import com.sun.comclient.calendar.socs.SOCSCalendar;
010:
011:        import com.sun.portal.app.sharedtasks.faces.beans.TaskListSessionBackingBean;
012:        import com.sun.portal.app.sharedtasks.faces.beans.TaskUserSessionBackingBean;
013:        import com.sun.portal.app.sharedtasks.util.CalTask;
014:        import com.sun.portal.app.sharedtasks.util.CalTaskListItem;
015:        import com.sun.portal.app.sharedtasks.util.SharedConstants;
016:        import com.sun.portal.app.sharedtasks.util.SharedTaskException;
017:
018:        import java.util.ArrayList;
019:
020:        import com.sun.portal.log.common.PortalLogger;
021:        import java.util.logging.Logger;
022:        import java.util.logging.Level;
023:
024:        /**
025:         * Model class representing a list of tasks, with capabilities
026:         * to search tasks, filter tasks by set criteria and delete groups
027:         * of tasks.
028:         *
029:         * @author ashwin.mathew@sun.com
030:         */
031:        public class TaskListModel {
032:
033:            private TaskListSessionBackingBean listSession;
034:
035:            private TaskUserSessionBackingBean userSession;
036:
037:            private static Logger logger = PortalLogger
038:                    .getLogger(TaskListModel.class);
039:
040:            private static final String SEARCH_PREFIX = "ALL=";
041:
042:            public TaskListModel(TaskListSessionBackingBean listSession,
043:                    TaskUserSessionBackingBean userSession) {
044:                this .listSession = listSession;
045:                this .userSession = userSession;
046:            }
047:
048:            public CalTaskListItem[] retrieve() throws SharedTaskException {
049:                if (logger.isLoggable(Level.FINEST)) {
050:                    logger.finest("Retrieving task list, search string ["
051:                            + listSession.getSearchString()
052:                            + "], view context ["
053:                            + listSession.getViewContext()
054:                            + "], view context date ["
055:                            + listSession.getViewDate() + "], status filter ["
056:                            + listSession.getStatusFilter() + "]");
057:                }
058:
059:                ArrayList results = new ArrayList();
060:
061:                try {
062:                    ICalendar cal = userSession.getCalendar();
063:
064:                    CalendarComponent[] tasks = null;
065:
066:                    if (listSession.getSearchString() != null) {
067:                        SOCSCalendar socsCal = (SOCSCalendar) cal;
068:                        tasks = socsCal.searchTodos(SEARCH_PREFIX
069:                                + listSession.getSearchString(), 0);
070:                    } else if (listSession.getViewContext() == null
071:                            // The condition below is a temporary fix. There are some cases
072:                            // where the view context arrives as an empty string, if
073:                            // it is not the default, and the filter has been applied
074:                            // such that an empty list is returned.
075:                            || listSession.getViewContext().length() == 0
076:                            || listSession.getViewContext().equals(
077:                                    SharedConstants.VIEW_CTX_DAY)) {
078:                        tasks = cal.fetchComponents(listSession
079:                                .getViewDateTime(), ICalendar.VTODO);
080:                    } else if (listSession.getViewContext().equals(
081:                            SharedConstants.VIEW_CTX_WEEK)
082:                            || listSession.getViewContext().equals(
083:                                    SharedConstants.VIEW_CTX_MONTH)) {
084:                        DateTime contextStartDateTime = listSession
085:                                .getContextStartDateTime();
086:                        DateTime contextEndDateTime = listSession
087:                                .getContextEndDateTime();
088:
089:                        tasks = cal.fetchComponents(contextStartDateTime,
090:                                contextEndDateTime, ICalendar.VTODO);
091:                    }
092:
093:                    for (int i = 0; i < tasks.length; i++) {
094:                        VTodo task = (VTodo) tasks[i];
095:
096:                        // If the status filter is set to view incomplete tasks and
097:                        // the current task is complete OR if the status filter is set
098:                        // to view complete tasks and the current task is incomplete,
099:                        // continue.
100:                        // If it's a full text search, ignore the filter.
101:                        if (listSession.getSearchString() == null
102:                                && listSession.getStatusFilter() != null
103:                                && ((listSession
104:                                        .getStatusFilter()
105:                                        .equals(
106:                                                SharedConstants.FILTER_INCOMPLETE_TASKS) && task
107:                                        .getPercent() == 100) || (listSession
108:                                        .getStatusFilter()
109:                                        .equals(
110:                                                SharedConstants.FILTER_COMPLETED_TASKS) && task
111:                                        .getPercent() < 100))) {
112:                            continue;
113:                        }
114:
115:                        CalTask calTask = new CalTask();
116:                        calTask.setTimeZone(userSession.getTimeZone());
117:                        calTask.load(task);
118:
119:                        CalTaskListItem item = new CalTaskListItem(calTask);
120:
121:                        results.add(item);
122:                    }
123:                } catch (CalendarException cex) {
124:                    logger.log(Level.SEVERE, "Error retrieving tasks", cex);
125:                    throw new SharedTaskException(
126:                            SharedTaskException.CALENDAR_ERROR, cex);
127:                } catch (OperationNotSupportedException onex) {
128:                    logger.log(Level.SEVERE, "Error retrieving tasks", onex);
129:                    throw new SharedTaskException(
130:                            SharedTaskException.CALENDAR_ERROR, onex);
131:                } catch (Exception ex) {
132:                    logger.log(Level.SEVERE, "Error retrieving tasks", ex);
133:                    throw new SharedTaskException(
134:                            SharedTaskException.APPLICATION_ERROR, ex);
135:                }
136:
137:                return (CalTaskListItem[]) results
138:                        .toArray(new CalTaskListItem[0]);
139:            }
140:
141:        }
w___w__w.__j__ava2_s__.__co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.