?? wfcmd.java
字號(hào):
{ } if(line !=null && line.length()>0) { li.addAttribute(Header.SUBJECT, new StringAttribute(line)); } // Optionally add some StringAttributes. // do { System.out.print("Attribute (leave empty to finish): "); String attr = reader.readLine().trim(); if(attr.length()==0) { break; } System.out.print("Value: "); String value = reader.readLine().trim(); if(li.getAttribute(attr)==null) { li.addAttribute(attr, new StringAttribute(value)); } else { li.setAttribute(attr, new StringAttribute(value)); } } while (true); session.launch(launch.getEngineId(), li); return CmdHandler.DO_NOT_EXIT; } } catch(Exception e) { System.err.println("Can't launch workflow: " + e); } return CmdHandler.DO_NOT_EXIT; } public Boolean do_exit (final String[] args) { return CmdHandler.DO_EXIT; } public Boolean do_quit (final String[] args) { return CmdHandler.DO_EXIT; } public void help_stores() { System.out.println("stores"); System.out.println(" Lists all of the stores in the worklist you are connected to. (It doesn't"); System.out.println(" tell you whether or not you have access to each of these stores.)"); } /** * List stores. * * @param args * @return * @throws Exception */ public Boolean do_stores(String[] args) throws Exception { for(Iterator it = session.getStoreNames().iterator(); it.hasNext();) { String name = (String)it.next(); System.out.println(" - '" + name + "'"); } return CmdHandler.DO_NOT_EXIT; } public void help_user() { System.out.println("user [<username> <password>]"); System.out.println(" If not parameters are specified, display the current user."); System.out.println(" Otherwise, start a new work session as this user and logout from the current session."); System.out.println(" If unsuccessful, the current session will continue to be used."); } public Boolean do_user(String[] args) { if(args.length==0) { try { Subject subject = session.getSubject(); System.out.println(subject); } catch(Exception e) { System.err.println("Can't get Subject: " + e); } return CmdHandler.DO_NOT_EXIT; } if(args.length!=2) { System.out.println("Required parameters not specified"); return CmdHandler.DO_NOT_EXIT; } String username = args[0]; String password = args[1]; try { WorkSessionServer sessionServer = (WorkSessionServer) Naming.lookup(url); WorkSession session = (WorkSession) sessionServer.login(username, password); // Switch sessions. // this.session.release(); this.session = session; } catch(Exception e) { System.out.println("Login not successful: " + e); } return CmdHandler.DO_NOT_EXIT; } public void help_workflows() { System.out.println("workflows"); System.out.println(" Lists all of the workflows that can be launched."); } /** * List launchable workflows. * * @param args * @return * @throws Exception */ public Boolean do_workflows(String[] args) throws Exception { for(Iterator it = session.getLaunchables().iterator(); it.hasNext();) { Launchable launch = (Launchable)it.next(); String description = language==null ? launch.getDefaultDescription() : launch.getDescription(language); System.out.println("Workflow url " + launch.getUrl()); System.out.println(" \"" + description + "\""); System.out.println(" Root element name: " + launch.getDescription("root.element.name")); System.out.println(" Engine Id: " + launch.getEngineId()); System.out.println(" isLaunchItem: " + launch.isLaunchItem()); System.out.println(); } return CmdHandler.DO_NOT_EXIT; } public static Header getHeader (final WorkSession session, final String storeName, final String id) throws Exception { List headers = session.getHeaders(storeName, DEFAULT_LIMIT); Header header = null; FlowExpressionId fei = null; for (Iterator i = headers.iterator(); i.hasNext();) { header = (Header)i.next(); if (header.getExpressionId().getWorkflowInstanceId().equals(id)) { return header; } } return null; } public static void displayAttributes(StringMapAttribute sma) { for(Iterator i = sma.stringKeySet().iterator(); i.hasNext();) { String key = (String)i.next(); Attribute attr = (Attribute)sma.get(key); String attrType = attr.getClass().getName(); attrType = attrType.substring(attrType.lastIndexOf(".")+1); System.out.print("\n" + key + " [" + attr + "] (" + attrType + ")"); } } public static void displayWorkItem(Header header, InFlowWorkItem wi) { StringMapAttribute wsma = header.getAttributes(); String title = "Workflow " + wsma.get(Header.WF_DEFINITION_NAME) + " " + wsma.get(Header.WF_DEFINITION_REVISION) + ": " + wsma.get(Header.WF_INSTANCE_ID); System.out.println("\n" + title); for(int i=0; i<title.length(); i++) { System.out.print("="); } System.out.println(); FlowExpressionId feId = wi.getLastExpressionId(); System.out.println("Last modified: " + wi.getLastModified()); System.out.println("Dispatch time: " + wi.getDispatchTime()); System.out.println("Participant: " + wi.getParticipantName()); System.out.println("Engine: " + feId.getEngineId()); System.out.println("WF def name: " + feId.getWorkflowDefinitionName()); System.out.println("WF def revision: " + feId.getWorkflowDefinitionRevision()); System.out.println("WF instance id: " + feId.getWorkflowInstanceId()); System.out.println("Expression name: " + feId.getExpressionName()); System.out.println("Expression id: " + feId.getExpressionId()); displayAttributes(wi.getAttributes()); if(wi.getHistory() != null) { System.out.println("\n\nHistory\n======="); for(Iterator i = wi.getHistory().iterator(); i.hasNext();) { HistoryItem hi = (HistoryItem)i.next(); System.out.println("Date: " + hi.getDate()); System.out.println("Author: " + hi.getAuthor()); System.out.println("Host: " + hi.getHost()); System.out.println("Text: " + hi.getText()); System.out.println("----"); } System.out.println(); } } public void run() { final CmdHandler parser = new CmdHandler(this); parser.commandLoop(prompt, reader); System.out.println("Bye."); System.exit(0); } public static void main(String[] args) { final String DEFAULT_URL = "rmi://localhost:7099/workSessionServer"; System.out.println(BANNER); if(args.length>0) { String arg = args[0].trim().toLowerCase(); if(arg.equals("-help") || arg.equals("-h") || arg.equals("-?")) { System.out.println("OpenWFE workflow client"); System.out.println(); System.out.println("Usage: " + WfCmd.class.getName() + " [<session server URL> [<username> [<password>]]"); System.out.println(); System.out.println("Default URL is " + DEFAULT_URL); System.exit(0); } } try { String url = args.length > 0 ? args[0] : DEFAULT_URL; BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // Get the username/password if not specified on the command line. // String username; if(args.length>1) { username = args[1]; } else { System.out.print("username> "); username = reader.readLine(); } String password; if(args.length>2) { password = args[2]; } else { System.out.print("password> "); password = reader.readLine(); } // Login to the session server. // WorkSessionServer sessionServer = (WorkSessionServer) Naming.lookup(url); WorkSession session = (WorkSession) sessionServer.login(username, password); new WfCmd(url, session, reader).run(); } catch (Exception e) { e.printStackTrace(); } }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -