Source Code Cross Referenced for DatabaseTaskoptions.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » scheduler » taskoptionmanagers » 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.taskoptionmanagers 
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: DatabaseTaskoptions.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.scheduler.taskoptionmanagers;
009:
010:        import com.uwyn.rife.database.queries.*;
011:        import com.uwyn.rife.scheduler.taskoptionmanagers.exceptions.*;
012:
013:        import com.uwyn.rife.database.Datasource;
014:        import com.uwyn.rife.database.DbPreparedStatement;
015:        import com.uwyn.rife.database.DbPreparedStatementHandler;
016:        import com.uwyn.rife.database.DbQueryManager;
017:        import com.uwyn.rife.database.DbRowProcessor;
018:        import com.uwyn.rife.database.exceptions.DatabaseException;
019:        import com.uwyn.rife.scheduler.Scheduler;
020:        import com.uwyn.rife.scheduler.Taskoption;
021:        import com.uwyn.rife.scheduler.TaskoptionManager;
022:        import com.uwyn.rife.scheduler.exceptions.TaskoptionManagerException;
023:        import java.sql.ResultSet;
024:        import java.sql.SQLException;
025:        import java.util.ArrayList;
026:        import java.util.Collection;
027:
028:        public abstract class DatabaseTaskoptions extends DbQueryManager
029:                implements  TaskoptionManager {
030:            private Scheduler mScheduler = null;
031:
032:            protected DatabaseTaskoptions(Datasource datasource) {
033:                super (datasource);
034:            }
035:
036:            public void setScheduler(Scheduler scheduler) {
037:                mScheduler = scheduler;
038:            }
039:
040:            public Scheduler getScheduler() {
041:                return mScheduler;
042:            }
043:
044:            public abstract boolean install() throws TaskoptionManagerException;
045:
046:            public abstract boolean remove() throws TaskoptionManagerException;
047:
048:            protected boolean _install(CreateTable createTableTaskoption)
049:                    throws TaskoptionManagerException {
050:                assert createTableTaskoption != null;
051:
052:                try {
053:                    executeUpdate(createTableTaskoption);
054:                } catch (DatabaseException e) {
055:                    throw new InstallTaskoptionsErrorException(e);
056:                }
057:
058:                return true;
059:            }
060:
061:            protected boolean _remove(DropTable dropTableTaskoption)
062:                    throws TaskoptionManagerException {
063:                assert dropTableTaskoption != null;
064:
065:                try {
066:                    executeUpdate(dropTableTaskoption);
067:                } catch (DatabaseException e) {
068:                    throw new RemoveTaskoptionsErrorException(e);
069:                }
070:
071:                return true;
072:            }
073:
074:            protected boolean _addTaskoption(Insert addTaskoption,
075:                    DbPreparedStatementHandler handler,
076:                    final Taskoption taskoption)
077:                    throws TaskoptionManagerException {
078:                assert addTaskoption != null;
079:
080:                if (null == taskoption)
081:                    throw new IllegalArgumentException(
082:                            "taskoption can't be null.");
083:
084:                boolean result = false;
085:
086:                try {
087:                    if (0 == executeUpdate(addTaskoption, handler)) {
088:                        throw new AddTaskoptionErrorException(taskoption);
089:                    }
090:                    result = true;
091:                } catch (DatabaseException e) {
092:                    throw new AddTaskoptionErrorException(taskoption, e);
093:                }
094:
095:                return result;
096:            }
097:
098:            protected boolean _updateTaskoption(Update updateTaskoption,
099:                    DbPreparedStatementHandler handler,
100:                    final Taskoption taskoption)
101:                    throws TaskoptionManagerException {
102:                assert updateTaskoption != null;
103:
104:                if (null == taskoption)
105:                    throw new IllegalArgumentException(
106:                            "taskoption can't be null.");
107:
108:                boolean result = false;
109:                try {
110:                    if (0 == executeUpdate(updateTaskoption, handler)) {
111:                        throw new UpdateTaskoptionErrorException(taskoption);
112:                    }
113:                    result = true;
114:                } catch (DatabaseException e) {
115:                    throw new UpdateTaskoptionErrorException(taskoption, e);
116:                }
117:
118:                return result;
119:            }
120:
121:            protected Taskoption _getTaskoption(Select getTaskoption,
122:                    ProcessTaskoption processTaskoption, final int taskId,
123:                    final String name) throws TaskoptionManagerException {
124:                assert getTaskoption != null;
125:
126:                if (taskId < 0)
127:                    throw new IllegalArgumentException(
128:                            "taskid can't be negative.");
129:                if (null == name)
130:                    throw new IllegalArgumentException("name can't be null.");
131:                if (0 == name.length())
132:                    throw new IllegalArgumentException("name can't be empty.");
133:
134:                Taskoption taskoption = null;
135:
136:                try {
137:                    executeFetchFirst(getTaskoption, processTaskoption,
138:                            new DbPreparedStatementHandler() {
139:                                public void setParameters(
140:                                        DbPreparedStatement statement) {
141:                                    statement.setInt("task_id", taskId)
142:                                            .setString("name", name);
143:                                }
144:                            });
145:                    taskoption = processTaskoption.getTaskoption();
146:                } catch (DatabaseException e) {
147:                    throw new GetTaskoptionErrorException(taskId, name, e);
148:                }
149:
150:                return taskoption;
151:            }
152:
153:            protected Collection<Taskoption> _getTaskoptions(
154:                    Select getTaskoptions, ProcessTaskoption processTaskoption,
155:                    final int taskId) throws TaskoptionManagerException {
156:                assert getTaskoptions != null;
157:
158:                if (taskId < 0)
159:                    throw new IllegalArgumentException(
160:                            "taskid can't be negative.");
161:
162:                ArrayList<Taskoption> taskoptions = new ArrayList<Taskoption>();
163:                processTaskoption.setCollection(taskoptions);
164:
165:                try {
166:                    executeFetchAll(getTaskoptions, processTaskoption,
167:                            new DbPreparedStatementHandler() {
168:                                public void setParameters(
169:                                        DbPreparedStatement statement) {
170:                                    statement.setInt("task_id", taskId);
171:                                }
172:                            });
173:                } catch (DatabaseException e) {
174:                    throw new GetTaskoptionsErrorException(taskId, e);
175:                }
176:
177:                assert taskoptions != null;
178:
179:                return taskoptions;
180:            }
181:
182:            protected boolean _removeTaskoption(Delete removeTaskoption,
183:                    Taskoption taskoption) throws TaskoptionManagerException {
184:                if (null == taskoption)
185:                    throw new IllegalArgumentException(
186:                            "taskoption can't be null.");
187:
188:                return _removeTaskoption(removeTaskoption, taskoption
189:                        .getTaskId(), taskoption.getName());
190:            }
191:
192:            protected boolean _removeTaskoption(Delete removeTaskoption,
193:                    final int taskId, final String name)
194:                    throws TaskoptionManagerException {
195:                assert removeTaskoption != null;
196:
197:                if (taskId < 0)
198:                    throw new IllegalArgumentException(
199:                            "taskid can't be negative.");
200:                if (null == name)
201:                    throw new IllegalArgumentException("name can't be null.");
202:                if (0 == name.length())
203:                    throw new IllegalArgumentException("name can't be empty.");
204:
205:                boolean result = false;
206:
207:                try {
208:                    if (0 != executeUpdate(removeTaskoption,
209:                            new DbPreparedStatementHandler() {
210:                                public void setParameters(
211:                                        DbPreparedStatement statement) {
212:                                    statement.setInt("task_id", taskId)
213:                                            .setString("name", name);
214:                                }
215:                            })) {
216:                        result = true;
217:                    }
218:                } catch (DatabaseException e) {
219:                    throw new RemoveTaskoptionErrorException(taskId, name, e);
220:                }
221:
222:                return result;
223:            }
224:
225:            protected class ProcessTaskoption extends DbRowProcessor {
226:                protected Collection<Taskoption> mCollection = null;
227:                protected Taskoption mTaskoption = null;
228:
229:                public ProcessTaskoption() {
230:                }
231:
232:                public void setCollection(Collection<Taskoption> collection) {
233:                    mCollection = collection;
234:                }
235:
236:                public boolean processRow(ResultSet resultSet)
237:                        throws SQLException {
238:                    assert resultSet != null;
239:
240:                    mTaskoption = new Taskoption();
241:
242:                    mTaskoption.setTaskId(resultSet.getInt("task_id"));
243:                    mTaskoption.setName(resultSet.getString("name"));
244:                    mTaskoption.setValue(resultSet.getString("value"));
245:
246:                    if (mCollection != null) {
247:                        mCollection.add(mTaskoption);
248:                    }
249:
250:                    return true;
251:                }
252:
253:                public Taskoption getTaskoption() {
254:                    return mTaskoption;
255:                }
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.