Source Code Cross Referenced for WfTaskSearchApple.java in  » Content-Management-System » daisy » org » outerj » daisy » frontend » workflow » 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 » Content Management System » daisy » org.outerj.daisy.frontend.workflow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Outerthought bvba and Schaubroeck nv
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.outerj.daisy.frontend.workflow;
017:
018:        import org.outerj.daisy.frontend.util.AbstractDaisyApple;
019:        import org.outerj.daisy.frontend.util.FormHelper;
020:        import org.outerj.daisy.frontend.util.XmlObjectXMLizable;
021:        import org.outerj.daisy.frontend.util.GenericPipeConfig;
022:        import org.outerj.daisy.frontend.FrontEndContext;
023:        import org.outerj.daisy.repository.Repository;
024:        import org.outerj.daisy.repository.query.SortOrder;
025:        import org.outerj.daisy.workflow.*;
026:        import org.apache.cocoon.components.flow.apples.StatelessAppleController;
027:        import org.apache.cocoon.components.flow.apples.AppleRequest;
028:        import org.apache.cocoon.components.flow.apples.AppleResponse;
029:        import org.apache.cocoon.forms.formmodel.Form;
030:        import org.apache.cocoon.forms.FormContext;
031:        import org.apache.cocoon.environment.Request;
032:        import org.apache.avalon.framework.service.Serviceable;
033:        import org.apache.avalon.framework.service.ServiceManager;
034:        import org.apache.avalon.framework.service.ServiceException;
035:        import org.apache.xmlbeans.XmlObject;
036:
037:        import java.util.*;
038:
039:        public class WfTaskSearchApple extends AbstractDaisyApple implements 
040:                StatelessAppleController, Serviceable {
041:            private ServiceManager serviceManager;
042:            private WorkflowManager workflowManager;
043:            private Locale locale;
044:            private Repository repository;
045:
046:            public void service(ServiceManager serviceManager)
047:                    throws ServiceException {
048:                this .serviceManager = serviceManager;
049:            }
050:
051:            protected void processRequest(AppleRequest appleRequest,
052:                    AppleResponse appleResponse) throws Exception {
053:                repository = frontEndContext.getRepository();
054:                workflowManager = (WorkflowManager) repository
055:                        .getExtension("WorkflowManager");
056:                locale = frontEndContext.getLocale();
057:
058:                String resource = appleRequest.getSitemapParameter("resource");
059:                if ("data".equals(resource)) {
060:                    getData(appleRequest, appleResponse);
061:                    return;
062:                }
063:
064:                Form form = FormHelper.createForm(serviceManager,
065:                        "resources/form/wftasksearch_definition.xml");
066:
067:                boolean endProcessing = false;
068:                if (request.getParameter("state") != null) { // state field is used here to check if the form is on the request
069:                    endProcessing = form.process(new FormContext(request,
070:                            locale));
071:                } else {
072:                    form.getChild("state").setValue("open");
073:                    form.getChild("assignedTo").setValue("me");
074:                    form.getChild("priority").setValue(new Long(5));
075:                }
076:
077:                Map<String, Object> viewData = new HashMap<String, Object>();
078:
079:                if (endProcessing) {
080:                    Map<String, String> params = new HashMap<String, String>();
081:
082:                    // State
083:                    String state = (String) form.getChild("state").getValue();
084:                    if (state != null)
085:                        params.put("state", state);
086:
087:                    // Description
088:                    String description = (String) form.getChild("description")
089:                            .getValue();
090:                    if (description != null)
091:                        params.put("description", description);
092:
093:                    // Assigned to
094:                    String assignedTo = (String) form.getChild("assignedTo")
095:                            .getValue();
096:                    if (assignedTo != null)
097:                        params.put("assignedTo", assignedTo);
098:
099:                    // Priority
100:                    Long priority = (Long) form.getChild("priority").getValue();
101:                    if (priority != null)
102:                        params.put("priority", priority.toString());
103:
104:                    // Process definition
105:                    String processDefinition = (String) form.getChild(
106:                            "processDefinition").getValue();
107:                    if (processDefinition != null)
108:                        params.put("processDefinition", processDefinition);
109:
110:                    String dataUrl = SearchHelper.buildUrl("taskSearch/data",
111:                            params);
112:
113:                    viewData.put("wfSearchResultDataUrl", dataUrl);
114:                }
115:
116:                viewData.put("locale", locale);
117:                viewData.put("pageContext", frontEndContext.getPageContext());
118:                viewData.put("CocoonFormsInstance", form);
119:                viewData.put("processDefinitions", workflowManager
120:                        .getAllLatestProcessDefinitions(locale)); // TODO retrieving this each time remotely is expensive
121:
122:                appleResponse.sendPage("Form-wftasksearch-Pipe", viewData);
123:            }
124:
125:            private void getData(AppleRequest appleRequest,
126:                    AppleResponse appleResponse) throws Exception {
127:                QueryConditions queryConditions = new QueryConditions();
128:                Request request = appleRequest.getCocoonRequest();
129:                FrontEndContext frontEndContext = FrontEndContext.get(request);
130:
131:                String state = request.getParameter("state");
132:                if (state == null) {
133:                    // ignore
134:                } else if (state.equals("open")) {
135:                    queryConditions.addCondition("task.isOpen",
136:                            WfValueType.BOOLEAN, "eq", Boolean.TRUE);
137:                } else if (state.equals("closed")) {
138:                    queryConditions.addCondition("task.isOpen",
139:                            WfValueType.BOOLEAN, "eq", Boolean.FALSE);
140:                }
141:
142:                // Description
143:                String description = request.getParameter("description");
144:                if (description != null) {
145:                    queryConditions.addProcessVariableCondition(
146:                            "daisy_description", WfValueType.STRING, "like",
147:                            description);
148:                }
149:
150:                // Assigned to
151:                String assignedTo = request.getParameter("assignedTo");
152:                if ("me".equals(assignedTo)) {
153:                    queryConditions.addCondition("task.actor",
154:                            WfValueType.USER, "eq", new WfUserKey(repository
155:                                    .getUserId()));
156:                } else if ("anyone".equals(assignedTo)) {
157:                    queryConditions.addCondition("task.actor",
158:                            WfValueType.USER, "is_not_null");
159:                } else if ("no-one".equals(assignedTo)) {
160:                    queryConditions.addCondition("task.actor",
161:                            WfValueType.USER, "is_null");
162:                }
163:
164:                // Priority
165:                String priority = request.getParameter("priority");
166:                if (priority != null) {
167:                    queryConditions
168:                            .addCondition("task.priority", WfValueType.LONG,
169:                                    "lt_eq", Long.parseLong(priority));
170:                }
171:
172:                // Process definition
173:                String processDefinition = request
174:                        .getParameter("processDefinition");
175:                if (processDefinition != null) {
176:                    queryConditions.addCondition("process.definitionName",
177:                            WfValueType.STRING, "eq", processDefinition);
178:                }
179:
180:                List<QuerySelectItem> selectItems = new ArrayList<QuerySelectItem>();
181:                selectItems.add(new QuerySelectItem("task.id",
182:                        QueryValueSource.PROPERTY));
183:                selectItems.add(new QuerySelectItem("daisy_description",
184:                        QueryValueSource.PROCESS_VARIABLE));
185:                selectItems.add(new QuerySelectItem("task.create",
186:                        QueryValueSource.PROPERTY));
187:                selectItems.add(new QuerySelectItem("task.definitionLabel",
188:                        QueryValueSource.PROPERTY));
189:                selectItems.add(new QuerySelectItem("task.priority",
190:                        QueryValueSource.PROPERTY));
191:                selectItems.add(new QuerySelectItem("task.actor",
192:                        QueryValueSource.PROPERTY));
193:                selectItems.add(new QuerySelectItem("task.dueDate",
194:                        QueryValueSource.PROPERTY));
195:                selectItems.add(new QuerySelectItem("process.suspended",
196:                        QueryValueSource.PROPERTY));
197:                selectItems.add(new QuerySelectItem("task.isOpen",
198:                        QueryValueSource.PROPERTY));
199:                selectItems.add(new QuerySelectItem("task.hasPools",
200:                        QueryValueSource.PROPERTY));
201:                selectItems.add(new QuerySelectItem("process.id",
202:                        QueryValueSource.PROPERTY));
203:                selectItems.add(new QuerySelectItem("daisy_owner",
204:                        QueryValueSource.PROCESS_VARIABLE));
205:
206:                // order by
207:                List<QueryOrderByItem> orderByItems = new ArrayList<QueryOrderByItem>();
208:                SearchHelper.OrderByParams orderByParams = SearchHelper
209:                        .getOrderByParams(request);
210:                if (orderByParams == null)
211:                    orderByParams = SearchHelper.getOrderByParams(
212:                            "task.create", QueryValueSource.PROPERTY,
213:                            SortOrder.DESCENDING);
214:                orderByItems.add(new QueryOrderByItem(orderByParams.orderBy,
215:                        orderByParams.orderBySource,
216:                        orderByParams.orderByDirection));
217:
218:                SearchHelper.OffsetParams offsetParams = SearchHelper
219:                        .getOffsetParams(request);
220:
221:                XmlObject result = workflowManager.searchTasks(selectItems,
222:                        queryConditions, orderByItems, offsetParams.offset,
223:                        offsetParams.length, locale);
224:
225:                Map<String, Object> viewData = new HashMap<String, Object>();
226:                viewData.put("wfSearchResult", new XmlObjectXMLizable(result));
227:                viewData.put("locale", locale);
228:                viewData.put("pageContext", frontEndContext.getPageContext());
229:                viewData.put("orderBy", orderByParams.orderBy);
230:                viewData.put("orderBySource", orderByParams.orderBySource
231:                        .toString());
232:                viewData.put("orderByDirection", orderByParams.orderByDirection
233:                        .toString());
234:                viewData.put("actionReturnTo", request
235:                        .getParameter("actionReturnTo"));
236:                viewData.put("actionReturnLabel", request
237:                        .getParameter("actionReturnLabel"));
238:
239:                GenericPipeConfig pipeConfig = new GenericPipeConfig();
240:                pipeConfig.setTemplate("resources/xml/wf_search_page.xml");
241:                pipeConfig
242:                        .setStylesheet("daisyskin:xslt/workflow/wf_tasks_searchresult.xsl");
243:                pipeConfig.setApplyLayout(false);
244:                viewData.put("pipeConf", pipeConfig);
245:
246:                appleResponse.sendPage("internal/genericPipe", viewData);
247:            }
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.