Source Code Cross Referenced for BatchSignalCommand.java in  » Workflow-Engines » jbpm-jpdl-3.2.2 » org » jbpm » command » 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 » Workflow Engines » jbpm jpdl 3.2.2 » org.jbpm.command 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jbpm.command;
002:
003:        import java.util.Date;
004:        import java.util.Iterator;
005:        import java.util.List;
006:
007:        import org.apache.commons.logging.Log;
008:        import org.apache.commons.logging.LogFactory;
009:        import org.hibernate.Query;
010:        import org.jbpm.JbpmContext;
011:        import org.jbpm.graph.def.ProcessDefinition;
012:        import org.jbpm.graph.exe.ProcessInstance;
013:        import org.jbpm.graph.exe.Token;
014:
015:        /**
016:         * a bunch of processes is signalled with this command. you can specify the
017:         * tokens either
018:         * <li> by a array of token ids
019:         * <li> or by processName, processVersion (optional, without all versions),
020:         * stateName
021:         * 
022:         * transitionName speicifies the transition to take (if null, the default
023:         * transition is taken).
024:         * 
025:         * This command can be for example useful, if you have a lot of processes to
026:         * check some information a not jBPM task has altered before (maybe in batch
027:         * too).
028:         * 
029:         * CURRENTLY EXPERIMENTAL! 
030:         * 
031:         * @author Bernd Rucker (bernd.ruecker@camunda.com)
032:         */
033:        public class BatchSignalCommand implements  Command {
034:
035:            private static final long serialVersionUID = -4330623193546102772L;
036:
037:            private static Log log = LogFactory
038:                    .getLog(BatchSignalCommand.class);
039:
040:            private long[] tokenIds = null;
041:
042:            private String processName = null;
043:
044:            private String stateName = null;
045:
046:            /**
047:             * if set, only tokens which are started after this date are signaled
048:             * (interessting to implement some timeout for example)
049:             */
050:            private Date inStateAtLeastSince = null;
051:
052:            private long processVersion = 0;
053:
054:            private String transitionName = null;
055:
056:            public Object execute(JbpmContext jbpmContext) throws Exception {
057:                log.debug("executing " + this );
058:
059:                // batch tokens
060:                if (tokenIds != null && tokenIds.length > 0) {
061:                    for (int i = 0; i < tokenIds.length; i++) {
062:                        Token token = jbpmContext
063:                                .loadTokenForUpdate(tokenIds[i]);
064:                        signalToken(token);
065:                    }
066:                }
067:
068:                // search for tokens in process/state
069:                if (processName != null && stateName != null) {
070:                    Query query = jbpmContext.getSession().getNamedQuery(
071:                            "GraphSession.findTokensForProcessInNode");
072:                    query.setString("processDefinitionName", processName);
073:                    query.setString("nodeName", stateName);
074:
075:                    Iterator iter = query.list().iterator();
076:                    while (iter.hasNext()) {
077:                        Token t = (Token) iter.next();
078:                        if (inStateAtLeastSince == null
079:                                || t.getNodeEnter().before(inStateAtLeastSince))
080:                            signalToken(t);
081:                    }
082:                }
083:
084:                return null;
085:            }
086:
087:            private void signalToken(Token token) {
088:                log.debug("signal token " + token);
089:                if (transitionName == null) {
090:                    token.signal();
091:                } else {
092:                    token.signal(transitionName);
093:                }
094:            }
095:
096:            public String getProcessName() {
097:                return processName;
098:            }
099:
100:            public void setProcessName(String processName) {
101:                this .processName = processName;
102:            }
103:
104:            public long getProcessVersion() {
105:                return processVersion;
106:            }
107:
108:            public void setProcessVersion(long processVersion) {
109:                this .processVersion = processVersion;
110:            }
111:
112:            public String getStateName() {
113:                return stateName;
114:            }
115:
116:            public void setStateName(String stateName) {
117:                this .stateName = stateName;
118:            }
119:
120:            public long[] getTokenIds() {
121:                return tokenIds;
122:            }
123:
124:            public void setTokenIds(long[] tokenIds) {
125:                this .tokenIds = tokenIds;
126:            }
127:
128:            public String getTransitionName() {
129:                return transitionName;
130:            }
131:
132:            public void setTransitionName(String transitionName) {
133:                this .transitionName = transitionName;
134:            }
135:
136:            public Date getInStateAtLeastSince() {
137:                return inStateAtLeastSince;
138:            }
139:
140:            public void setInStateAtLeastSince(Date inStateAtLeastSince) {
141:                this.inStateAtLeastSince = inStateAtLeastSince;
142:            }
143:
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.