Source Code Cross Referenced for ExecuteTaskForm.java in  » Portal » mypersonalizer » es » udc » mypersonalizer » admin » http » view » actionforms » tasks » 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 » mypersonalizer » es.udc.mypersonalizer.admin.http.view.actionforms.tasks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Admin/Sources/es/udc/mypersonalizer/admin/http/view/actionforms/tasks/ExecuteTaskForm.java,v 1.1.1.1 2004/03/25 12:08:39 fbellas Exp $
003:         * $Revision: 1.1.1.1 $
004:         * $Date: 2004/03/25 12:08:39 $
005:         *
006:         * =============================================================================
007:         *
008:         * Copyright (c) 2003, The MyPersonalizer Development Group
009:         * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at 
010:         * University Of A Coru�a
011:         * All rights reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions are met:
015:         *
016:         *  - Redistributions of source code must retain the above copyright notice, 
017:         *    this list of conditions and the following disclaimer.
018:         *
019:         *  - Redistributions in binary form must reproduce the above copyright notice,
020:         *    this list of conditions and the following disclaimer in the documentation
021:         *    and/or other materials provided with the distribution.
022:         *
023:         *  - Neither the name of the University Of A Coru�a nor the names of its 
024:         *    contributors may be used to endorse or promote products derived from 
025:         *    this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
028:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
036:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037:         * POSSIBILITY OF SUCH DAMAGE.
038:         *
039:         */
040:        package es.udc.mypersonalizer.admin.http.view.actionforms.tasks;
041:
042:        import javax.servlet.http.HttpServletRequest;
043:
044:        import org.apache.struts.action.ActionError;
045:        import org.apache.struts.action.ActionErrors;
046:        import org.apache.struts.action.ActionForm;
047:        import org.apache.struts.action.ActionMapping;
048:
049:        import es.udc.mypersonalizer.kernel.model.query.ast.Query;
050:        import es.udc.mypersonalizer.kernel.model.query.ast.Step;
051:        import es.udc.mypersonalizer.kernel.model.query.parser.ParseException;
052:        import es.udc.mypersonalizer.kernel.model.query.parser.QueryParser;
053:        import es.udc.mypersonalizer.kernel.model.tasks.Task;
054:
055:        /**
056:         * Form used to execute an action.
057:         * 
058:         * @author Abel Muinho
059:         * @author David barral
060:         * @since 1.0
061:         */
062:        public class ExecuteTaskForm extends ActionForm {
063:
064:            private String query;
065:
066:            private String taskName;
067:
068:            private boolean doPreview;
069:
070:            private boolean fromForm;
071:
072:            private Query compiledQuery;
073:
074:            private Task taskInstance;
075:
076:            private int startIndex = 0;
077:
078:            private int count = 10;
079:
080:            /**
081:             * Obtains the index of first property to be shown.
082:             * @return the first property index. 
083:             */
084:            public int getStartIndex() {
085:                return startIndex;
086:            }
087:
088:            /**
089:             * Sets the index of first property to be shown.
090:             * @param value the first property index. 
091:             */
092:            public void setStartIndex(int value) {
093:                startIndex = value;
094:            }
095:
096:            /**
097:             * Obtains the number of properties to show at once
098:             * @return the number of properties.
099:             */
100:            public int getCount() {
101:                return count;
102:            }
103:
104:            /**
105:             * Sets the number of properties to show at once.
106:             * @param value number of properties.
107:             */
108:            public void setCount(int value) {
109:                count = value;
110:            }
111:
112:            /**
113:             * Obtains the query, as a <code>String</code>, to be executed.
114:             * @return the query string.
115:             */
116:            public String getQuery() {
117:                return query;
118:            }
119:
120:            /**
121:             * Sets the query, as a <code>String</code>, to be executed.
122:             * @param string the query string.
123:             */
124:            public void setQuery(String string) {
125:                query = string;
126:            }
127:
128:            /**
129:             * Obtains the name of the task to perform.
130:             * @return the name of the task.
131:             */
132:            public String getTaskName() {
133:                return taskName;
134:            }
135:
136:            /**
137:             * Sets the name of the task to perform.
138:             * @param string the name of the task.
139:             */
140:            public void setTaskName(String string) {
141:                taskName = string;
142:            }
143:
144:            /**
145:             * Obtains the flag that marks if the query results must be previewed
146:             * @return true if preview is selected
147:             */
148:            public boolean getDoPreview() {
149:                return doPreview;
150:            }
151:
152:            /**
153:             * Sets the flag that marks if the query results must be previewed
154:             * @param doPreview true if preview is desired
155:             */
156:            public void setDoPreview(boolean doPreview) {
157:                this .doPreview = doPreview;
158:            }
159:
160:            /**
161:             * Obtains the flag that marks if the associated <code>Action</code> was 
162:             * called from a form or from the menu
163:             * @return true if called from a form.
164:             */
165:            public boolean getFromForm() {
166:                return this .fromForm;
167:            }
168:
169:            /**
170:             * Sets the flag that marks if the associated <code>Action</code> was 
171:             * called from a form or from the menu
172:             * @param fromForm true if called from a form
173:             */
174:            public void setFromForm(boolean fromForm) {
175:                this .fromForm = fromForm;
176:            }
177:
178:            /**
179:             * Returns the <code>Query</code> object representing the query string.
180:             * <p>
181:             * The query will be generated during validation.
182:             * @return the query compiled during validation.
183:             */
184:            public Query getCompiledQuery() {
185:                return compiledQuery;
186:            }
187:
188:            /**
189:             * Returns the <code>Task</code> instance represented by the 
190:             * <code>taskName</code> parameter.
191:             * <p>
192:             * The object will be generated during validation.
193:             * @return the <code>Task</code> to be executed.
194:             */
195:            public Task getTaskInstance() {
196:                return taskInstance;
197:            }
198:
199:            public ActionErrors validate(ActionMapping mapping,
200:                    HttpServletRequest request) {
201:
202:                compiledQuery = null;
203:                taskInstance = null;
204:
205:                ActionErrors errors = new ActionErrors();
206:
207:                if (query == null || query.trim().length() == 0) {
208:                    /* The query must be filled. */
209:                    errors.add("query", new ActionError(
210:                            "Query.Executor.emptyQueryError"));
211:                } else {
212:                    /* The query must be well formed. */
213:                    try {
214:                        QueryParser parser = new QueryParser();
215:                        compiledQuery = parser.parse(query);
216:                    } catch (ParseException e) {
217:                        errors.add("query", new ActionError(
218:                                "Query.Executor.parseError", e.getMessage()));
219:                    }
220:                }
221:
222:                try {
223:                    /* The task must be instantiable. */
224:                    taskInstance = (Task) Class.forName(taskName).newInstance();
225:                } catch (Exception e) {
226:                    errors.add("taskName", new ActionError(
227:                            "Query.Executor.missingImplementationError"));
228:                }
229:
230:                /* If the query was well formed, check if it is compatible with the
231:                 * selected task.
232:                 */
233:                if (compiledQuery != null && taskInstance != null) {
234:                    /* Find target property */
235:                    Step lastStep = (Step) compiledQuery.getReturnClause().get(
236:                            compiledQuery.getReturnClause().size() - 1);
237:
238:                    if (!taskInstance.isCompatibleWith(lastStep
239:                            .getMetaProperty())) {
240:                        errors.add("taskName", new ActionError(
241:                                "Query.Executor.incompatibleTarget"));
242:                    }
243:                }
244:                return errors;
245:            }
246:
247:            public void reset(ActionMapping mapping, HttpServletRequest request) {
248:                reset();
249:            }
250:
251:            private void reset() {
252:                query = "";
253:                taskName = "";
254:                compiledQuery = null;
255:                taskInstance = null;
256:                startIndex = 0;
257:                count = 10;
258:                doPreview = false;
259:                fromForm = false;
260:            }
261:
262:        }
w__w___w.__ja__v__a___2_s__.__c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.