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


001:        package com.sun.portal.app.sharedtasks.util;
002:
003:        import com.sun.comclient.calendar.Attendee;
004:        import com.sun.comclient.calendar.Organizer;
005:        import com.sun.comclient.calendar.CalendarComponentException;
006:        import com.sun.comclient.calendar.DateTime;
007:        import com.sun.comclient.calendar.OperationNotSupportedException;
008:        import com.sun.comclient.calendar.PropertiesException;
009:        import com.sun.comclient.calendar.RecurrencePattern;
010:        import com.sun.comclient.calendar.VTodo;
011:        import com.sun.comclient.calendar.socs.SOCSTodo;
012:        import java.io.Serializable;
013:        import java.text.ParseException;
014:        import java.util.Calendar;
015:        import java.util.Date;
016:        import java.util.TimeZone;
017:        import javax.faces.context.FacesContext;
018:        import javax.faces.component.UIComponent;
019:        import javax.faces.validator.ValidatorException;
020:        import javax.faces.application.FacesMessage;
021:
022:        /**
023:         * Basic representation of all the data fields on a calendar task.
024:         */
025:        public class CalTask implements  Serializable {
026:
027:            /**
028:             * Priority options.
029:             */
030:            public static final String PRIORITY_NONE = "NONE";
031:            public static final String PRIORITY_LOW = "LOW";
032:            public static final String PRIORITY_NORMAL = "NORMAL";
033:            public static final String PRIORITY_HIGH = "HIGH";
034:
035:            /**
036:             * Status options.
037:             */
038:            public static final String STATUS_0 = "0";
039:            public static final String STATUS_25 = "25";
040:            public static final String STATUS_50 = "50";
041:            public static final String STATUS_75 = "75";
042:            public static final String STATUS_100 = "100";
043:
044:            private VTodo task;
045:
046:            private String id;
047:
048:            private String rid;
049:
050:            private String title;
051:
052:            private String description;
053:
054:            private String location;
055:
056:            private String priority;
057:
058:            private String status;
059:
060:            private DateTime startDateTime;
061:
062:            private boolean isStartDateTimeSet = false;
063:
064:            private Boolean noStartDate = Boolean.FALSE;
065:
066:            private DateTime dueDateTime;
067:
068:            private boolean isDueDateTimeSet = false;
069:
070:            private Boolean noDueDate = Boolean.FALSE;
071:
072:            private String recurrencePattern = CalTaskRepeat.REPEAT_ONE_TIME
073:                    .getRString(); // Default
074:
075:            private int recurrenceCount = 1; // Default
076:
077:            String[] attendeeIds = null;
078:
079:            String organizerId = null;
080:
081:            private TimeZone timeZone;
082:
083:            /**
084:             * Creates a new instance of CalTask
085:             */
086:            public CalTask() {
087:                startDateTime = new DateTime();
088:                dueDateTime = new DateTime();
089:            }
090:
091:            // Note that attendee ids are not being loaded. This is not required
092:            // for this release, and should be done as a lazy load if required
093:            // since the array may be large.
094:            public void load(VTodo task) throws OperationNotSupportedException,
095:                    CalendarComponentException {
096:                this .task = task;
097:
098:                this .id = task.getID();
099:
100:                if (task.getRecurrenceID() != null) {
101:                    this .rid = task.getRecurrenceID().toISOString();
102:                }
103:
104:                this .title = task.getSummary();
105:                this .description = task.getDescription();
106:                this .location = task.getLocation();
107:
108:                int statusInt = task.getPercent();
109:                status = String.valueOf(statusInt);
110:
111:                int priorityInt = task.getPriority();
112:                switch (priorityInt) {
113:                case 0:
114:                    priority = CalTask.PRIORITY_NONE;
115:                    break;
116:                case 1:
117:                case 2:
118:                case 3:
119:                case 4:
120:                    priority = CalTask.PRIORITY_HIGH;
121:                    break;
122:                case 5:
123:                    priority = CalTask.PRIORITY_NORMAL;
124:                    break;
125:                case 6:
126:                case 7:
127:                case 8:
128:                case 9:
129:                    priority = CalTask.PRIORITY_LOW;
130:                    break;
131:                default:
132:                    priority = CalTask.PRIORITY_NONE;
133:                    break;
134:                }
135:
136:                startDateTime = task.getStart();
137:                if (startDateTime == null) {
138:                    startDateTime = new DateTime(); //Prevent NPEs
139:                    noStartDate = Boolean.TRUE;
140:                } else {
141:                    if (timeZone != null) {
142:                        startDateTime.setTimeZone(timeZone);
143:                    }
144:                    noStartDate = Boolean.FALSE;
145:                }
146:
147:                dueDateTime = task.getEnd();
148:                if (dueDateTime == null) {
149:                    dueDateTime = new DateTime(); //Prevent NPEs
150:                    noDueDate = Boolean.TRUE;
151:                } else {
152:                    if (timeZone != null) {
153:                        dueDateTime.setTimeZone(timeZone);
154:                    }
155:                    noDueDate = Boolean.FALSE;
156:                }
157:
158:                RecurrencePattern[] rPatterns = task.getRecurrenceRules();
159:                if (rPatterns != null) {
160:                    RecurrencePattern rPattern = rPatterns[0];
161:                    this .recurrenceCount = rPattern.getCount();
162:                    this .recurrencePattern = CalTaskRepeat
163:                            .getStringForPattern(rPattern);
164:                }
165:
166:                Organizer organizer = task.getOrganizer();
167:                if (organizer != null) {
168:                    this .organizerId = organizer.getValue();
169:                }
170:            }
171:
172:            public void copyToVTodo(VTodo task)
173:                    throws OperationNotSupportedException,
174:                    CalendarComponentException, PropertiesException {
175:                this .task = task;
176:
177:                if (id != null) // Will be null for a new task
178:                {
179:                    task.setID(id);
180:                }
181:
182:                if (rid != null) {
183:                    try {
184:                        task.setProperty(SOCSTodo.RECURRENCE_ID, new DateTime(
185:                                rid));
186:                    } catch (ParseException e) {
187:                        // Ignore, will never happen
188:                    }
189:                }
190:
191:                if (title != null) {
192:                    task.setSummary(title);
193:                }
194:
195:                if (description != null) {
196:                    task.setDescription(description);
197:                }
198:
199:                if (location != null) {
200:                    task.setLocation(location);
201:                }
202:
203:                if (status == null) {
204:                    status = CalTask.STATUS_0;
205:                }
206:                int statusInt = Integer.parseInt(status);
207:                task.setPercent(statusInt);
208:
209:                // Set priority values as per RFC 2445
210:                int priorityInt = 0;
211:                if (priority == null || priority.equals(PRIORITY_NONE)) {
212:                    priorityInt = 0;
213:                } else if (priority.equals(PRIORITY_LOW)) {
214:                    priorityInt = 9;
215:                } else if (priority.equals(PRIORITY_NORMAL)) {
216:                    priorityInt = 5;
217:                } else if (priority.equals(PRIORITY_HIGH)) {
218:                    priorityInt = 1;
219:                }
220:                task.setPriority(priorityInt);
221:
222:                if (noStartDate.equals(Boolean.FALSE) && isStartDateTimeSet) {
223:                    startDateTime.setTimeZone(timeZone);
224:                    task.setStart(startDateTime);
225:                }
226:
227:                if (noDueDate.equals(Boolean.FALSE) && isDueDateTimeSet) {
228:                    dueDateTime.setTimeZone(timeZone);
229:                    task.setEnd(dueDateTime);
230:                }
231:
232:                if (recurrencePattern != null
233:                        && !recurrencePattern
234:                                .equals(CalTaskRepeat.REPEAT_ONE_TIME
235:                                        .getRString())) {
236:                    RecurrencePattern rPattern = CalTaskRepeat.makeRPattern(
237:                            recurrencePattern, recurrenceCount);
238:                    task.addRecurrenceRule(rPattern);
239:                }
240:
241:                if (attendeeIds != null) {
242:                    for (int i = 0; i < attendeeIds.length; i++) {
243:                        Attendee attendee = new Attendee(Attendee.INDIVIDUAL,
244:                                attendeeIds[i]);
245:                        task.addAttendee(attendee);
246:                    }
247:                }
248:
249:                if (organizerId != null) {
250:                    Organizer organizer = new Organizer(null, organizerId);
251:                    task.setOrganizer(organizer);
252:                }
253:            }
254:
255:            public void validateDueDate() throws SharedTaskException {
256:                if (dueDateTime != null && dueDateTime.before(startDateTime)) {
257:                    throw new SharedTaskException(
258:                            SharedTaskException.INVALID_DUE_DATE);
259:                }
260:            }
261:
262:            public void validateRecurrenceCount() throws SharedTaskException {
263:                if (recurrenceCount < 1 || recurrenceCount > 60) {
264:                    throw new SharedTaskException(
265:                            SharedTaskException.INVALID_RECCURENCE_COUNT);
266:                }
267:            }
268:
269:            // For debug purposes, as required
270:            public String toString() {
271:                StringBuffer out = new StringBuffer();
272:
273:                out.append("Title [").append(title).append("] \n");
274:                out.append("Description [").append(description).append("] \n");
275:                out.append("Location [").append(location).append("] \n");
276:                out.append("Priority [").append(priority).append("] \n");
277:                out.append("Status [").append(status).append("] \n");
278:                out.append("Recurrence pattern [").append(recurrencePattern)
279:                        .append("] \n");
280:                out.append("Recurrence count [").append(recurrenceCount)
281:                        .append("] \n");
282:                out.append("noDueDate [").append(noDueDate).append("] \n");
283:                out.append("noStartDate [").append(noStartDate).append("] \n");
284:                out.append("Start Date [").append(startDateTime.toISO8601())
285:                        .append("] \n");
286:                out.append("Due Date [").append(dueDateTime.toISO8601())
287:                        .append("] \n");
288:
289:                return out.toString();
290:            }
291:
292:            public String getTitle() {
293:                return title;
294:            }
295:
296:            public void setTitle(String title) {
297:                this .title = title;
298:            }
299:
300:            public String getDescription() {
301:                return description;
302:            }
303:
304:            public void setDescription(String description) {
305:                this .description = description;
306:            }
307:
308:            public String getLocation() {
309:                return location;
310:            }
311:
312:            public void setLocation(String location) {
313:                this .location = location;
314:            }
315:
316:            public String getPriority() {
317:                return priority;
318:            }
319:
320:            public void setPriority(String priority) {
321:                this .priority = priority;
322:            }
323:
324:            public String getStatus() {
325:                return status;
326:            }
327:
328:            public void setStatus(String status) {
329:                this .status = status;
330:            }
331:
332:            public Date getStartDate() {
333:                return startDateTime.getTime();
334:            }
335:
336:            public DateTime getStartTime() {
337:                return startDateTime;
338:            }
339:
340:            public void setStartDate(Date startDate) {
341:                if (startDate != null) {
342:                    startDateTime.setTime(startDate);
343:                    isStartDateTimeSet = true;
344:                }
345:            }
346:
347:            public String getStartHour() {
348:                return String.valueOf(startDateTime.getHours());
349:            }
350:
351:            public void setStartHour(String startHourStr) {
352:                if (startHourStr != null) {
353:                    startDateTime.setHours(Integer.parseInt(startHourStr));
354:                } else {
355:                    startDateTime.setHours(0);
356:                }
357:            }
358:
359:            public String getStartMin() {
360:                return String.valueOf(startDateTime.getMinutes());
361:            }
362:
363:            public void setStartMin(String startMinStr) {
364:                if (startMinStr != null) {
365:                    startDateTime.setMinutes(Integer.parseInt(startMinStr));
366:                } else {
367:                    startDateTime.setMinutes(0);
368:                }
369:            }
370:
371:            public Boolean getNoStartDate() {
372:                return noStartDate;
373:            }
374:
375:            public void setNoStartDate(Boolean noStartDate) {
376:                this .noStartDate = noStartDate;
377:            }
378:
379:            public Date getDueDate() {
380:                return dueDateTime.getTime();
381:            }
382:
383:            public DateTime getDueTime() {
384:                return dueDateTime;
385:            }
386:
387:            public void setDueDate(Date dueDate) {
388:                if (dueDate != null) {
389:                    dueDateTime.setTime(dueDate);
390:                    isDueDateTimeSet = true;
391:                }
392:            }
393:
394:            public String getDueHour() {
395:                return String.valueOf(dueDateTime.getHours());
396:            }
397:
398:            public void setDueHour(String dueHourStr) {
399:                if (dueHourStr != null) {
400:                    dueDateTime.setHours(Integer.parseInt(dueHourStr));
401:                } else {
402:                    dueDateTime.setHours(0);
403:                }
404:            }
405:
406:            public String getDueMin() {
407:                return String.valueOf(dueDateTime.getMinutes());
408:            }
409:
410:            public void setDueMin(String dueMinStr) {
411:                if (dueMinStr != null) {
412:                    dueDateTime.setMinutes(Integer.parseInt(dueMinStr));
413:                } else {
414:                    dueDateTime.setMinutes(0);
415:                }
416:            }
417:
418:            public Boolean getNoDueDate() {
419:                return noDueDate;
420:            }
421:
422:            public void setNoDueDate(Boolean noDueDate) {
423:                this .noDueDate = noDueDate;
424:            }
425:
426:            public String getId() {
427:                return id;
428:            }
429:
430:            public void setId(String id) {
431:                this .id = id;
432:            }
433:
434:            public String getRid() {
435:                return rid;
436:            }
437:
438:            public void setRid(String rid) {
439:                this .rid = rid;
440:            }
441:
442:            public boolean getIsRecurring() {
443:                return (!recurrencePattern.equals(CalTaskRepeat.REPEAT_ONE_TIME
444:                        .getRString()));
445:            }
446:
447:            public String getRecurrencePattern() {
448:                return recurrencePattern;
449:            }
450:
451:            public void setRecurrencePattern(String recurrencePattern) {
452:                this .recurrencePattern = recurrencePattern;
453:            }
454:
455:            public int getRecurrenceCount() {
456:                return recurrenceCount;
457:            }
458:
459:            public void setRecurrenceCount(int recurrenceCount) {
460:                this .recurrenceCount = recurrenceCount;
461:            }
462:
463:            // Not implementing getAttendeeIds, we don't need it for
464:            // this release.
465:            public void setAttendeeIds(String[] attendeeIds) {
466:                this .attendeeIds = attendeeIds;
467:            }
468:
469:            public String getOrganizerId() {
470:                return organizerId;
471:            }
472:
473:            public void setOrganizerId(String organizerId) {
474:                this .organizerId = organizerId;
475:            }
476:
477:            public TimeZone getTimeZone() {
478:                return timeZone;
479:            }
480:
481:            public void setTimeZone(TimeZone timeZone) {
482:                this .timeZone = timeZone;
483:
484:                // Need to set these again here, since timezone *may*
485:                // be called after the object is loaded.
486:                startDateTime.setTimeZone(timeZone);
487:                dueDateTime.setTimeZone(timeZone);
488:            }
489:
490:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.