Source Code Cross Referenced for Task.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » scheduler » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.scheduler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: Task.java 3714 2007-04-08 02:57:38Z gbevin $
007:         */
008:        package com.uwyn.rife.scheduler;
009:
010:        import com.uwyn.rife.config.RifeConfig;
011:        import com.uwyn.rife.scheduler.exceptions.FrequencyException;
012:        import com.uwyn.rife.scheduler.exceptions.SchedulerException;
013:        import com.uwyn.rife.site.Validation;
014:        import com.uwyn.rife.site.ValidationError;
015:        import com.uwyn.rife.site.ValidationRule;
016:        import com.uwyn.rife.site.ValidationRuleNotEmpty;
017:        import com.uwyn.rife.site.ValidationRuleNotNull;
018:        import com.uwyn.rife.tools.Localization;
019:        import java.util.Calendar;
020:        import java.util.Date;
021:
022:        public class Task extends Validation implements  Cloneable {
023:            private int mId = -1;
024:            private String mType = null;
025:            private long mPlanned = 0;
026:            private Frequency mFrequency = null;
027:            private boolean mBusy = false;
028:
029:            private TaskManager mTaskManager = null;
030:
031:            public Task() {
032:            }
033:
034:            protected void activateValidation() {
035:                addRule(new ValidationRuleNotNull("type"));
036:                addRule(new ValidationRuleNotEmpty("planned"));
037:                addRule(new InvalidPlanned());
038:            }
039:
040:            public void setTaskManager(TaskManager taskManager) {
041:                mTaskManager = taskManager;
042:            }
043:
044:            public TaskManager getTaskManager() {
045:                return mTaskManager;
046:            }
047:
048:            public String getTaskoptionValue(String name)
049:                    throws SchedulerException {
050:                if (null == name)
051:                    throw new IllegalArgumentException("name can't be null.");
052:                if (0 == name.length())
053:                    throw new IllegalArgumentException("name can't be empty.");
054:
055:                if (null == mTaskManager) {
056:                    return null;
057:                }
058:
059:                Scheduler scheduler = mTaskManager.getScheduler();
060:                if (null == scheduler) {
061:                    return null;
062:                }
063:
064:                TaskoptionManager taskoption_manager = scheduler
065:                        .getTaskoptionManager();
066:                if (null == taskoption_manager) {
067:                    return null;
068:                }
069:
070:                Taskoption taskoption = taskoption_manager.getTaskoption(
071:                        getId(), name);
072:                if (null == taskoption) {
073:                    return null;
074:                }
075:
076:                return taskoption.getValue();
077:            }
078:
079:            public long getNextDate() throws FrequencyException {
080:                // lower towards the minute, remove seconds and milliseconds
081:                Calendar current_calendar = Calendar.getInstance(
082:                        RifeConfig.Tools.getDefaultTimeZone(), Localization
083:                                .getLocale());
084:                current_calendar.set(Calendar.SECOND, 0);
085:                current_calendar.set(Calendar.MILLISECOND, 0);
086:                long current_time = current_calendar.getTimeInMillis();
087:                if (mPlanned <= current_time) {
088:                    return getNextDate(current_time);
089:                }
090:
091:                return -1;
092:            }
093:
094:            public long getNextDate(long start) throws FrequencyException {
095:                if (null == mFrequency) {
096:                    return -1;
097:                } else {
098:                    return mFrequency.getNextDate(start);
099:                }
100:            }
101:
102:            public void setId(int id) {
103:                mId = id;
104:            }
105:
106:            public int getId() {
107:                return mId;
108:            }
109:
110:            public void setType(String type) {
111:                mType = type;
112:            }
113:
114:            public String getType() {
115:                return mType;
116:            }
117:
118:            public void setPlanned(Date planned) {
119:                setPlanned(planned.getTime());
120:            }
121:
122:            public void setPlanned(long planned) {
123:                // lower towards the minute, remove seconds and milliseconds
124:                Calendar planned_calendar = Calendar.getInstance(
125:                        RifeConfig.Tools.getDefaultTimeZone(), Localization
126:                                .getLocale());
127:                planned_calendar.setTimeInMillis(planned);
128:                planned_calendar.set(Calendar.SECOND, 0);
129:                planned_calendar.set(Calendar.MILLISECOND, 0);
130:
131:                mPlanned = planned_calendar.getTimeInMillis();
132:            }
133:
134:            public long getPlanned() {
135:                return mPlanned;
136:            }
137:
138:            public void setFrequency(String frequency)
139:                    throws FrequencyException {
140:                if (null == frequency) {
141:                    mFrequency = null;
142:                } else {
143:                    mFrequency = new Frequency(frequency);
144:                }
145:            }
146:
147:            public String getFrequency() {
148:                if (null == mFrequency) {
149:                    return null;
150:                }
151:                return mFrequency.getFrequency();
152:            }
153:
154:            public void setBusy(boolean busy) {
155:                mBusy = busy;
156:            }
157:
158:            public boolean isBusy() {
159:                return mBusy;
160:            }
161:
162:            public Task clone() throws CloneNotSupportedException {
163:                return (Task) super .clone();
164:            }
165:
166:            public boolean equals(Object object) {
167:                Task other_task = (Task) object;
168:
169:                if (null != object
170:                        && other_task.getId() == getId()
171:                        && other_task.getType().equals(getType())
172:                        && other_task.getPlanned() == getPlanned()
173:                        && ((null == other_task.getFrequency() && null == getFrequency()) || (other_task
174:                                .getFrequency() != null && other_task
175:                                .getFrequency().equals(getFrequency())))
176:                        && other_task.getTaskManager() == getTaskManager()) {
177:                    return true;
178:                }
179:
180:                return false;
181:            }
182:
183:            public class InvalidPlanned implements  ValidationRule {
184:                public boolean validate() {
185:                    if (0 == mPlanned) {
186:                        return true;
187:                    }
188:
189:                    Calendar current_calendar = Calendar.getInstance(
190:                            RifeConfig.Tools.getDefaultTimeZone(), Localization
191:                                    .getLocale());
192:                    current_calendar.set(Calendar.SECOND, 0);
193:                    current_calendar.set(Calendar.MILLISECOND, 0);
194:                    return mPlanned >= current_calendar.getTimeInMillis();
195:                }
196:
197:                public String getSubject() {
198:                    return "planned";
199:                }
200:
201:                public ValidationError getError() {
202:                    return new ValidationError.INVALID(getSubject());
203:                }
204:
205:                public Object getBean() {
206:                    return null;
207:                }
208:
209:                public <T extends ValidationRule> T setBean(Object bean) {
210:                    return (T) this ;
211:                }
212:
213:                public Object clone() {
214:                    return this;
215:                }
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.