Source Code Cross Referenced for RequestActivationNode.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » engine » node » 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 » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.engine.node 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.engine.node;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collections;
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        import org.apache.log4j.MDC;
025:
026:        import edu.iu.uis.eden.EdenConstants;
027:        import edu.iu.uis.eden.KEWServiceLocator;
028:        import edu.iu.uis.eden.actionrequests.ActionRequestValue;
029:        import edu.iu.uis.eden.engine.RouteContext;
030:        import edu.iu.uis.eden.engine.RouteHelper;
031:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
032:        import edu.iu.uis.eden.exception.ResourceUnavailableException;
033:        import edu.iu.uis.eden.exception.WorkflowException;
034:        import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
035:        import edu.iu.uis.eden.util.PerformanceLogger;
036:        import edu.iu.uis.eden.util.Utilities;
037:
038:        /**
039:         * A node which will activate any requests on it, returning true when there are no more requests 
040:         * which require activation.
041:         * 
042:         * @author ewestfal
043:         */
044:        public class RequestActivationNode implements  SimpleNode {
045:
046:            protected final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
047:                    .getLogger(getClass());
048:            private static long generatedRequestPriority = 0;
049:
050:            public SimpleResult process(RouteContext routeContext,
051:                    RouteHelper routeHelper) throws Exception {
052:                DocumentRouteHeaderValue document = routeContext.getDocument();
053:                RouteNodeInstance nodeInstance = routeContext.getNodeInstance();
054:                if (routeContext.isSimulation()) {
055:                    if (routeContext.getActivationContext()
056:                            .isActionsToPerform()) {
057:                        activateRequests(routeContext, document, nodeInstance);
058:                    }
059:                    return new SimpleResult(true);
060:                } else if (!activateRequests(routeContext, document,
061:                        nodeInstance)
062:                        && shouldTransition(document, nodeInstance)) {
063:                    return new SimpleResult(true);
064:                } else {
065:                    return new SimpleResult(false);
066:                }
067:            }
068:
069:            public boolean shouldTransition(DocumentRouteHeaderValue document,
070:                    RouteNodeInstance nodeInstance) {
071:                List requests = KEWServiceLocator.getActionRequestService()
072:                        .findPendingRootRequestsByDocIdAtRouteNode(
073:                                document.getRouteHeaderId(),
074:                                nodeInstance.getRouteNodeInstanceId());
075:                boolean shouldTransition = true;
076:                for (Iterator iterator = requests.iterator(); iterator
077:                        .hasNext();) {
078:                    ActionRequestValue request = (ActionRequestValue) iterator
079:                            .next();
080:                    if (request.isApproveOrCompleteRequest()) {
081:                        shouldTransition = false;
082:                        break;
083:                    }
084:                }
085:                return shouldTransition;
086:            }
087:
088:            /**
089:             * Activates the action requests that are pending at this routelevel of the document. The requests are processed by priority and then request ID. It is implicit in the access that the requests are activated according to the route level above all.
090:             * <p>
091:             * FYI and acknowledement requests do not cause the processing to stop. Only action requests for approval or completion cause the processing to stop and then only for route level with a serialized activation policy. Only requests at the current document's current route level are activated. Inactive requests at a lower level cause a routing exception.
092:             * <p>
093:             * Exception routing and adhoc routing are processed slightly differently.
094:             * 
095:             * @param rh
096:             *            RouteHeaderBean object for which requests are activated
097:             * @return True if the any approval actions were activated.
098:             * @throws ResourceUnavailableException
099:             * @throws WorkflowException
100:             */
101:            public boolean activateRequests(RouteContext context,
102:                    DocumentRouteHeaderValue document,
103:                    RouteNodeInstance nodeInstance) throws WorkflowException {
104:                MDC.put("docID", document.getRouteHeaderId());
105:                PerformanceLogger performanceLogger = new PerformanceLogger(
106:                        document.getRouteHeaderId());
107:                List generatedActionItems = new ArrayList();
108:                List requests = KEWServiceLocator.getActionRequestService()
109:                        .findPendingRootRequestsByDocIdAtRouteNode(
110:                                document.getRouteHeaderId(),
111:                                nodeInstance.getRouteNodeInstanceId());
112:                if (context.isSimulation()) {
113:                    requests.addAll(context.getEngineState()
114:                            .getGeneratedRequests());
115:                }
116:                Collections
117:                        .sort(requests, new Utilities().new PrioritySorter());
118:                LOG.debug("Pending Root Requests " + requests.size());
119:                String activationType = nodeInstance.getRouteNode()
120:                        .getActivationType();
121:                boolean isParallel = EdenConstants.ROUTE_LEVEL_PARALLEL
122:                        .equals(activationType);
123:                boolean activatedApproveRequest = false;
124:                for (Iterator iter = requests.iterator(); iter.hasNext();) {
125:                    if (activatedApproveRequest && !isParallel) {
126:                        break;
127:                    }
128:                    ActionRequestValue request = (ActionRequestValue) iter
129:                            .next();
130:                    if (request.getParentActionRequest() != null
131:                            || request.getNodeInstance() == null) {
132:                        // 1. disregard request if it's not a top-level request
133:                        // 2. disregard request if it's a "future" request and hasn't been attached to a node instance yet
134:                        continue;
135:                    }
136:                    if (request.isActive()) {
137:                        activatedApproveRequest = activatedApproveRequest
138:                                || request.isApproveOrCompleteRequest();
139:                        continue;
140:                    }
141:                    logProcessingMessage(request);
142:                    LOG.debug("Activating request.");
143:                    activatedApproveRequest = activateRequest(context, request,
144:                            nodeInstance, generatedActionItems)
145:                            || activatedApproveRequest;
146:                }
147:                // now let's send notifications, since this code needs to be able to activate each request individually, we need
148:                // to collection all action items and then notify after all have been generated
149:                if (!context.isSimulation()) {
150:                    KEWServiceLocator.getNotificationService().notify(
151:                            generatedActionItems);
152:                }
153:                performanceLogger.log("Time to activate requests.");
154:                return activatedApproveRequest;
155:            }
156:
157:            private boolean activateRequest(RouteContext context,
158:                    ActionRequestValue actionRequest,
159:                    RouteNodeInstance nodeInstance, List generatedActionItems)
160:                    throws EdenUserNotFoundException {
161:                if (actionRequest.isRoleRequest()) {
162:                    List actionRequests = KEWServiceLocator
163:                            .getActionRequestService()
164:                            .findPendingRootRequestsByDocIdAtRouteNode(
165:                                    actionRequest.getRouteHeaderId(),
166:                                    nodeInstance.getRouteNodeInstanceId());
167:                    for (Iterator iterator = actionRequests.iterator(); iterator
168:                            .hasNext();) {
169:                        ActionRequestValue siblingRequest = (ActionRequestValue) iterator
170:                                .next();
171:                        if (actionRequest.getRoleName().equals(
172:                                siblingRequest.getRoleName())) {
173:                            generatedActionItems.addAll(KEWServiceLocator
174:                                    .getActionRequestService()
175:                                    .activateRequestNoNotification(
176:                                            siblingRequest,
177:                                            context.getActivationContext()));
178:                        }
179:                    }
180:                }
181:                generatedActionItems.addAll(KEWServiceLocator
182:                        .getActionRequestService()
183:                        .activateRequestNoNotification(actionRequest,
184:                                context.getActivationContext()));
185:                return actionRequest.isApproveOrCompleteRequest()
186:                        && !actionRequest.isDone();
187:            }
188:
189:            protected void saveActionRequest(RouteContext context,
190:                    ActionRequestValue actionRequest)
191:                    throws EdenUserNotFoundException {
192:                if (!context.isSimulation()) {
193:                    KEWServiceLocator.getActionRequestService()
194:                            .saveActionRequest(actionRequest);
195:                } else {
196:                    actionRequest.setActionRequestId(new Long(
197:                            generatedRequestPriority++));
198:                    context.getEngineState().getGeneratedRequests().add(
199:                            actionRequest);
200:                }
201:
202:            }
203:
204:            protected void saveDocument(RouteContext context,
205:                    DocumentRouteHeaderValue document) {
206:                if (!context.isSimulation()) {
207:                    KEWServiceLocator.getRouteHeaderService().saveRouteHeader(
208:                            document);
209:                }
210:            }
211:
212:            private void logProcessingMessage(ActionRequestValue request) {
213:                if (LOG.isDebugEnabled()) {
214:                    RouteNodeInstance nodeInstance = request.getNodeInstance();
215:                    StringBuffer buffer = new StringBuffer();
216:                    buffer.append("Processing AR: ").append(
217:                            request.getActionRequestId()).append("\n");
218:                    buffer.append("AR Node Name: ").append(
219:                            nodeInstance != null ? nodeInstance.getName()
220:                                    : "null").append("\n");
221:                    buffer.append("AR RouteLevel: ").append(
222:                            request.getRouteLevel()).append("\n");
223:                    buffer.append("AR Request Code: ").append(
224:                            request.getActionRequested()).append("\n");
225:                    buffer.append("AR Request priority: ").append(
226:                            request.getPriority()).append("\n");
227:                    LOG.debug(buffer);
228:                }
229:            }
230:
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.