Source Code Cross Referenced for CLAdmin.java in  » Workflow-Engines » obe-1.0 » org » obe » admin » 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 » obe 1.0 » org.obe.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.obe.admin;
002:
003:        import java.io.IOException;
004:        import org.obe.client.AbstractCLClient;
005:        import org.obe.client.api.WMClient;
006:        import org.wfmc.wapi.*;
007:
008:        /**
009:         * A command line interface to OBE administrative functions.
010:         *
011:         * @author Adrian Price
012:         */
013:        public class CLAdmin extends AbstractCLClient {
014:            private static final Object[][] PROCESS_DEFINITIONS_MENU = {
015:                    // mnemonic, description, method
016:                    { "1", "List Process Definitions", "listProcessDefinitions" },
017:                    { "2", "Change Process Definition State",
018:                            "changeProcessDefinitionState" },
019:                    { "3", "Import Package", "importPackage" },
020:                    { "4", "Update Package", "updatePackage" },
021:                    { "5", "Export Package", "exportPackage" },
022:                    { "6", "Delete Package", "deletePackage" },
023:                    PRINT_LAST_EXCEPTION, MENU, BACK };
024:            private static final Object[][] PROCESS_INSTANCES_MENU = {
025:                    // mnemonic, description, method
026:                    { "1", "List Process Instances", "listProcessInstances" },
027:                    { "2", "List Process Instance Audit Entries",
028:                            "listProcessInstanceAuditEntries" },
029:                    { "3", "List Process Instance Attributes",
030:                            "listProcessInstanceAttributes" },
031:                    { "4", "Show Process Instance Attribute",
032:                            "showProcessInstanceAttribute" },
033:                    { "5", "Assign Process Attribute",
034:                            "assignProcessInstanceAttribute" },
035:                    { "6", "Create Process Instance", "createProcessInstance" },
036:                    { "7", "Change Process Instance State",
037:                            "changeProcessInstanceState" },
038:                    { "8", "Start a Process Instance", "startProcessInstance" },
039:                    { "9", "Delete a Process Instance", "deleteProcessInstance" },
040:                    { "A", "Delete Process Instances", "deleteProcessInstances" },
041:                    PRINT_LAST_EXCEPTION, MENU, BACK };
042:            private static final Object[][] ACTIVITY_INSTANCES_MENU = {
043:                    // mnemonic, description, method
044:                    { "1", "List Activity Instances",
045:                            "listProcessInstanceActivities" },
046:                    { "2", "List Activity Instance Attributes",
047:                            "listActivityInstanceAttributes" },
048:                    { "3", "Show Activity Instance Attribute",
049:                            "showActivityInstanceAttribute" },
050:                    { "4", "Change Activity Instance State",
051:                            "changeActivityInstanceState" },
052:                    PRINT_LAST_EXCEPTION, MENU, BACK };
053:            private static final Object[][] WORKLIST_MENU = {
054:                    // mnemonic, description, method
055:                    { "1", "List Work Items by Activity",
056:                            "listWorkItemsbyActivityInstance" },
057:                    { "2", "List Work Items by Performer",
058:                            "listWorkItemsByPerformer" },
059:                    { "3", "List Work Items by Participant",
060:                            "listWorkItemsByUser" },
061:                    { "4", "List Work Items by Process Instance",
062:                            "listWorkItemsByProcessInstance" },
063:                    { "5", "List Work Item Attributes",
064:                            "listWorkItemAttributes" },
065:                    { "6", "Show Work Item Attribute", "showWorkItemAttribute" },
066:                    { "7", "Change Work Item State", "changeWorkItemState" },
067:                    { "8", "Execute a Work Item", "executeWorkItem" },
068:                    PRINT_LAST_EXCEPTION, MENU, BACK };
069:            private static final Object[][] MAIN_MENU = {
070:                    // mnemonic, description, method
071:                    { "1", "Set Client Protocol", "setClientProtocol" },
072:                    { "2", "Connect", "connect" },
073:                    { "3", "Disconnect", "disconnect" },
074:                    { "4", "Process Definitions", PROCESS_DEFINITIONS_MENU },
075:                    { "5", "Process Instances", PROCESS_INSTANCES_MENU },
076:                    { "6", "Activity Instances", ACTIVITY_INSTANCES_MENU },
077:                    { "7", "Worklist", WORKLIST_MENU },
078:                    { "8", "Set Logging Level", "setLoggingLevel" },
079:                    PRINT_LAST_EXCEPTION, MENU, { "Q", "Quit", "quit" } };
080:
081:            public static void main(String[] args) {
082:                // usage: org.obe.admin.CLAdmin [hostUrl [userId [password]]]
083:                new CLAdmin(args).doMenu("Main Menu", MAIN_MENU, true);
084:            }
085:
086:            public CLAdmin(String[] args) {
087:                super (args, "OBE Command Line Administration Console");
088:            }
089:
090:            public void deletePackage() throws IOException {
091:                _pkgId = prompt("\nEnter package ID", _pkgId);
092:                if (_pkgId.equals("")) {
093:                    _stdout.println("\007*** Cancelled");
094:                    return;
095:                }
096:                // Confirm the delete.
097:                _stdout.print("Permanently delete package '" + _pkgId
098:                        + "' and all of its workflow definitions?");
099:                if (!getChoice("YN").equals("Y")) {
100:                    _stdout.println("\007*** Cancelled");
101:                    return;
102:                }
103:
104:                try {
105:                    _client.deletePackage(_pkgId);
106:                    _stdout.println("- Successfully deleted package '" + _pkgId
107:                            + '\'');
108:                    _pkgId = null;
109:                } catch (Exception e) {
110:                    _lastException = e;
111:                    _stdout.println("\007*** Failed to delete package [ID: "
112:                            + _pkgId + "] (" + e + ')');
113:                }
114:            }
115:
116:            public void exportPackage() throws IOException {
117:                _pkgId = prompt("\nEnter package ID", _pkgId);
118:                if (_pkgId.equals("")) {
119:                    _stdout.println("\007*** Cancelled");
120:                    return;
121:                }
122:                _file = prompt("\nEnter XPDL filename", _file);
123:                if (_file.equals("")) {
124:                    _stdout.println("\007*** Cancelled");
125:                    return;
126:                }
127:                if (!checkFile(_file))
128:                    return;
129:
130:                try {
131:                    String xpdl = _client.getPackageContent(_pkgId,
132:                            WMClient.XPDL);
133:                    writeFile(_file, xpdl);
134:
135:                    _stdout.println("- Successfully exported package '"
136:                            + _pkgId + '\'');
137:                } catch (Exception e) {
138:                    _lastException = e;
139:                    _stdout.println("\007*** Failed to export package [ID: "
140:                            + _pkgId + "] (" + e + ')');
141:                }
142:                return;
143:            }
144:
145:            public void updatePackage() throws IOException {
146:                _pkgId = prompt("\nEnter package ID", _pkgId);
147:                if (_pkgId.equals("")) {
148:                    _stdout.println("\007*** Cancelled");
149:                    return;
150:                }
151:                _file = prompt("\nEnter XPDL filename", _file);
152:                if (_file.equals("")) {
153:                    _stdout.println("\007*** Cancelled");
154:                    return;
155:                }
156:                String xpdl = readFile(_file);
157:
158:                try {
159:                    _client.setPackageContent(_pkgId, xpdl, WMClient.XPDL);
160:
161:                    _stdout.println("- Successfully updated package '" + _pkgId
162:                            + '\'');
163:                } catch (Exception e) {
164:                    _lastException = e;
165:                    _stdout.println("\007*** Failed to update package [ID: "
166:                            + _pkgId + "] (" + e + ')');
167:                }
168:            }
169:
170:            public void importPackage() throws IOException {
171:                _file = prompt("\nEnter XPDL filename", _file);
172:                if (_file.equals("")) {
173:                    _stdout.println("\007*** Cancelled");
174:                    return;
175:                }
176:                String xpdl = readFile(_file);
177:
178:                try {
179:                    _pkgId = _client.createPackage(xpdl, WMClient.XPDL);
180:
181:                    _stdout.println("- Successfully imported package '"
182:                            + _pkgId + '\'');
183:                } catch (Exception e) {
184:                    _lastException = e;
185:                    _stdout.println("\007*** Failed to import package [ID: "
186:                            + _pkgId + "] (" + e + ')');
187:                }
188:            }
189:
190:            public void changeProcessDefinitionState() throws IOException {
191:                _procDefId = prompt("\nEnter process definition ID", _procDefId);
192:                if (_procDefId.equals("")) {
193:                    _stdout.println("\007*** Cancelled");
194:                    return;
195:                }
196:                _newState = prompt("\nEnter new state", _newState);
197:                if (_newState.equals("")) {
198:                    _stdout.println("\007*** Cancelled");
199:                    return;
200:                }
201:
202:                try {
203:                    _client.changeProcessDefinitionState(_procDefId,
204:                            WMProcessDefinitionState.valueOf(_newState));
205:
206:                    _stdout
207:                            .println("- Successfully changed process definition # "
208:                                    + _procDefId
209:                                    + " state to '"
210:                                    + _newState
211:                                    + '\'');
212:                } catch (Exception e) {
213:                    _lastException = e;
214:                    _stdout
215:                            .println("\007*** Failed to change process definition state [ID: "
216:                                    + _procDefId + "] (" + e + ')');
217:                }
218:            }
219:
220:            public void deleteProcessInstances() throws IOException {
221:                _procDefId = prompt("\nEnter process definition ID", _procDefId);
222:                if (_procDefId.equals("")) {
223:                    _stdout.println("\007*** Cancelled");
224:                    return;
225:                }
226:                _filtExpr = prompt("\nEnter filter expression", _filtExpr);
227:
228:                // Confirm the delete.
229:                _stdout
230:                        .print("Permanently delete specified process instances?");
231:                if (!getChoice("YN").equals("Y")) {
232:                    _stdout.println("\007*** Cancelled");
233:                    return;
234:                }
235:
236:                try {
237:                    WMFilter filter = _filtExpr == null ? null : new WMFilter(
238:                            _filtExpr);
239:                    _client.deleteProcessInstances(_procDefId, filter);
240:                    _stdout.println("- Successfully deleted process instances");
241:                    _procInstId = null;
242:                } catch (Exception e) {
243:                    _lastException = e;
244:                    _stdout
245:                            .println("\007*** Failed to delete process instances");
246:                }
247:            }
248:
249:            public void deleteProcessInstance() throws IOException {
250:                _procInstId = prompt("\nEnter process instance ID", _procInstId);
251:                if (_procInstId.equals("")) {
252:                    _stdout.println("\007*** Cancelled");
253:                    return;
254:                }
255:                // Confirm the delete.
256:                _stdout.print("Permanently delete process instance '"
257:                        + _procInstId
258:                        + "' and all of its activities and work items?");
259:                if (!getChoice("YN").equals("Y")) {
260:                    _stdout.println("\007*** Cancelled");
261:                    return;
262:                }
263:
264:                try {
265:                    _client.deleteProcessInstance(_procInstId);
266:                    _stdout.println("- Successfully deleted process instance '"
267:                            + _procInstId + '\'');
268:                    _procInstId = null;
269:                } catch (Exception e) {
270:                    _lastException = e;
271:                    _stdout
272:                            .println("\007*** Failed to delete process instance [ID: "
273:                                    + _procInstId + "] (" + e + ')');
274:                }
275:            }
276:
277:            public void changeProcessInstanceState() throws IOException {
278:                _procInstId = prompt("\nEnter process instance ID", _procInstId);
279:                if (_procInstId.equals("")) {
280:                    _stdout.println("\007*** Cancelled");
281:                    return;
282:                }
283:                _newState = prompt("\nEnter new state", _newState);
284:                if (_newState.equals("")) {
285:                    _stdout.println("\007*** Cancelled");
286:                    return;
287:                }
288:
289:                try {
290:                    _client.changeProcessInstanceState(_procInstId,
291:                            WMProcessInstanceState.valueOf(_newState));
292:
293:                    _stdout
294:                            .println("- Successfully changed process instance # "
295:                                    + _procInstId
296:                                    + " state to '"
297:                                    + _newState
298:                                    + '\'');
299:                } catch (Exception e) {
300:                    _lastException = e;
301:                    _stdout
302:                            .println("\007*** Failed to change process instance state [ID: "
303:                                    + _procInstId + "] (" + e + ')');
304:                }
305:            }
306:
307:            public void assignProcessInstanceAttribute() throws IOException,
308:                    WMWorkflowException {
309:
310:                _procInstId = prompt("\nEnter process instance ID", _procInstId);
311:                if (_procInstId.equals("")) {
312:                    _stdout.println("\007*** Cancelled");
313:                    return;
314:                }
315:                _attrName = prompt("\nAttribute Name", _attrName);
316:                if (_attrName.equals("")) {
317:                    _stdout.println("\007*** Cancelled");
318:                    return;
319:                }
320:                assignProcessInstanceAttribute(_procInstId, _attrName);
321:            }
322:
323:            public void listProcessInstances() throws WMWorkflowException {
324:                WMProcessInstanceIterator procs = _client.listProcessInstances(
325:                        null, false);
326:
327:                // Format the list.
328:                _stdout.setTabs(PROC_INST_TABS);
329:                _stdout.println("Process Instances:");
330:                println(PROC_INST_FIELDS);
331:                _stdout.println(UNDERLINE);
332:                Object[] values = new String[4];
333:                while (procs.hasNext()) {
334:                    WMProcessInstance proc = procs.tsNext();
335:                    values[0] = proc.getId();
336:                    values[1] = proc.getName();
337:                    values[2] = String.valueOf(proc.getPriority());
338:                    values[3] = proc.getState().stringValue();
339:                    println(values);
340:                }
341:            }
342:
343:            public void changeActivityInstanceState() throws IOException {
344:                _actInstId = prompt("\nEnter activity instance ID", _actInstId);
345:                if (_actInstId.equals("")) {
346:                    _stdout.println("\007*** Cancelled");
347:                    return;
348:                }
349:                _newState = prompt("\nEnter new state", _newState);
350:                if (_newState.equals("")) {
351:                    _stdout.println("\007*** Cancelled");
352:                    return;
353:                }
354:
355:                try {
356:                    _client.changeActivityInstanceState(_procInstId,
357:                            _actInstId, WMActivityInstanceState
358:                                    .valueOf(_newState));
359:
360:                    _stdout
361:                            .println("- Successfully changed activity instance # "
362:                                    + _actInstId
363:                                    + " state to '"
364:                                    + _newState
365:                                    + '\'');
366:                } catch (Exception e) {
367:                    _lastException = e;
368:                    _stdout
369:                            .println("\007*** Failed to change activity instance state [ID: "
370:                                    + _actInstId + "] (" + e + ')');
371:                }
372:            }
373:
374:            public void showActivityInstanceAttribute() throws IOException {
375:                _actInstId = prompt("\nEnter activity instance ID", _actInstId);
376:                if (_actInstId.equals("")) {
377:                    _stdout.println("\007*** Cancelled");
378:                    return;
379:                }
380:                _attrName = prompt("\nAttribute Name", _attrName);
381:                if (_attrName.equals("")) {
382:                    _stdout.println("\007*** Cancelled");
383:                    return;
384:                }
385:                try {
386:                    WMAttribute attr = _client
387:                            .getActivityInstanceAttributeValue(null,
388:                                    _actInstId, _attrName);
389:                    _stdout.println("Attribute value: " + attr);
390:                } catch (WMWorkflowException e) {
391:                    _lastException = e;
392:                    _stdout
393:                            .println("\007*** Failed to get activity instance attribute [ID: "
394:                                    + _actInstId + "] (" + e + ')');
395:                }
396:            }
397:
398:            public void listActivityInstanceAttributes() throws IOException,
399:                    WMWorkflowException {
400:
401:                _actInstId = prompt("\nEnter activity instance ID", _actInstId);
402:                if (_actInstId.equals("")) {
403:                    _stdout.println("\007*** Cancelled");
404:                    return;
405:                }
406:
407:                // Retrieve activity instance attributes.
408:                WMAttributeIterator attrs = _client
409:                        .listActivityInstanceAttributes(null, _actInstId, null,
410:                                false);
411:
412:                // Format the results.
413:                listAttributes("Activity Instance", attrs);
414:            }
415:
416:            public void listProcessInstanceActivities() throws IOException,
417:                    WMWorkflowException {
418:
419:                WMActivityInstanceIterator activities;
420:                _procInstId = prompt("List activities for process instance ID",
421:                        _procInstId);
422:                if (_procInstId.equals("")) {
423:                    _stdout.println("\007*** Cancelled");
424:                    return;
425:                }
426:
427:                // Get activity instance list.
428:                WMFilter filter = new WMFilter("processInstanceId",
429:                        WMFilter.EQ, _procInstId);
430:                activities = _client.listActivityInstances(filter, false);
431:
432:                // Format the results.
433:                _stdout.setTabs(ACTIVITY_INSTANCE_TABS);
434:                _stdout.println("Activity Instances:");
435:                println(ACTIVITY_INSTANCE_FIELDS);
436:                _stdout.println(UNDERLINE);
437:                Object[] values = new Object[4];
438:                while (activities.hasNext()) {
439:                    WMActivityInstance activity = activities.tsNext();
440:                    values[0] = activity.getId();
441:                    values[1] = activity.getName();
442:                    values[2] = String.valueOf(activity.getPriority());
443:                    values[3] = activity.getState().stringValue();
444:                    println(values);
445:                }
446:            }
447:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.