Changeset 1262 for EDIS/trunk/java/vistalink-tester
- Timestamp:
- Oct 16, 2011, 4:47:09 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EDIS/trunk/java/vistalink-tester/src/main/java/gov/va/med/edp/VistaLinkTester.java
r1260 r1262 4 4 import gov.va.med.edp.vistalink.locator.VistaLinkConnectorConfig; 5 5 import gov.va.med.edp.vistalink.locator.VistaLinkConnectorConfigConnectionFactoryLocator; 6 import gov.va.med.vistalink.adapter.cci.VistaLinkResourceException; 6 7 import joptsimple.OptionException; 7 8 import joptsimple.OptionParser; 8 9 import joptsimple.OptionSet; 9 10 import joptsimple.OptionSpec; 11 import org.springframework.dao.DataAccessResourceFailureException; 10 12 11 13 import java.io.Console; 12 14 import java.io.IOException; 13 15 import java.util.ArrayList; 16 import java.util.Arrays; 14 17 import java.util.HashSet; 15 18 import java.util.List; … … 20 23 public static void main(String[] args) throws IOException { 21 24 OptionParser parser = new OptionParser(); 22 OptionSpec<String> hostOption = parser.acceptsAll(asList("S", "server", "host")).withRequiredArg().ofType(String.class); 23 OptionSpec<Integer> portOption = parser.acceptsAll(asList("P", "port")).withRequiredArg().ofType(Integer.class); 24 OptionSpec<String> divisionOption = parser.acceptsAll(asList("D", "division", "station-num")).withRequiredArg().ofType(String.class); 25 OptionSpec<String> rpcContextOption = parser.acceptsAll(asList("C", "context", "rpc-context")).withRequiredArg().ofType(String.class); 26 OptionSpec<String> rpcNameOption = parser.acceptsAll(asList("N", "name", "rpc-name")).withRequiredArg().ofType(String.class); 25 parser.acceptsAll(asList("?", "help"), "Print usage information"); 26 OptionSpec<String> hostOption = parser.acceptsAll(asList("S", "server", "host"), "Hostname or IP where VistALink is listening").withRequiredArg().ofType(String.class); 27 OptionSpec<Integer> portOption = parser.acceptsAll(asList("P", "port"), "Port where VistALink is listening").withRequiredArg().ofType(Integer.class); 28 OptionSpec<String> divisionOption = parser.acceptsAll(asList("D", "division", "station-num"), "Station Number").withRequiredArg().ofType(String.class); 29 OptionSpec<String> duzOption = parser.acceptsAll(asList("U", "DUZ")).withRequiredArg().ofType(String.class); 30 OptionSpec<String> rpcContextOption = parser.acceptsAll(asList("C", "context", "rpc-context"), "RPC Context").withRequiredArg().ofType(String.class); 31 OptionSpec<String> rpcNameOption = parser.acceptsAll(asList("N", "name", "rpc-name"), "RPC Name").withRequiredArg().ofType(String.class); 27 32 28 33 try { 29 34 OptionSet options = parser.parse(args); 35 36 if (options.has("?") || options.has("help")) { 37 System.out.println("Usage:"); 38 parser.printHelpOn(System.out); 39 System.exit(0); 40 } 30 41 31 42 Console console = System.console(); … … 33 44 String host = options.has(hostOption) ? hostOption.value(options) : console.readLine("Host: "); 34 45 int port = options.has(portOption) ? portOption.value(options) : Integer.parseInt(console.readLine("Port: ")); 35 String division = options.has(divisionOption) ? divisionOption.value(options) : console.readLine(" Division: ");46 String division = options.has(divisionOption) ? divisionOption.value(options) : console.readLine("Station Number: "); 36 47 37 char[] accessCode = console.readPassword("Access: ");38 char[] verifyCode = console.readPassword("Verify: ");48 char[] accessCodeChars = console.readPassword("Access: "); 49 char[] verifyCodeChars = console.readPassword("Verify: "); 39 50 51 String accessCode = new String(accessCodeChars); 52 String verifyCode = new String(verifyCodeChars); 53 54 String duz = options.has(duzOption) ? duzOption.value(options) : console.readLine("DUZ: "); 40 55 String rpcContext = options.has(rpcContextOption) ? rpcContextOption.value(options) : console.readLine("RPC Context: "); 41 56 String rpcName = options.has(rpcNameOption) ? rpcNameOption.value(options) : console.readLine("RPC Name: "); 42 ;43 57 44 58 if (rpcContext == null) rpcContext = ""; 45 59 46 VistaLinkTester tester = new VistaLinkTester(host, port, division, accessCode .toString(), verifyCode.toString());60 VistaLinkTester tester = new VistaLinkTester(host, port, division, accessCode, verifyCode); 47 61 48 62 System.out.println("Enter RPC Parameters (^ when finished)"); … … 61 75 } 62 76 63 System.out.println("Executing vlink://" + division + "@" + host + ":" + port + "/" + rpcContext + "/" + rpcName );77 System.out.println("Executing vlink://" + division + "@" + host + ":" + port + "/" + rpcContext + "/" + rpcName + formatRpcParams(params)); 64 78 65 System.out.println(tester.execute( rpcContext, rpcName, params));79 System.out.println(tester.execute(duz, rpcContext, rpcName, params)); 66 80 } catch (OptionException e) { 67 81 System.out.println(e.getLocalizedMessage()); … … 69 83 parser.printHelpOn(System.out); 70 84 System.exit(1); 85 } catch (gov.va.med.edp.vistalink.VistaLinkDataRetrievalFailureException e) { 86 System.out.println(e.getMessage()); 71 87 } catch (Throwable t) { 72 88 t.printStackTrace(); 73 89 } 74 // HashSet connectors = new HashSet(); 75 // connectors.add(new VistaLinkConnectorConfig("500", "WORLDVISTA DEMO CLINIC", "66.206.177.84", 9310, "EDISUSER1", "VISTAIS#1")); 90 } 91 92 private static String formatRpcParams(List params) { 93 StringBuilder b = new StringBuilder(); 94 if (!params.isEmpty()) b.append("?"); 95 for (int i = 0; i < params.size(); i++) { 96 b.append("["); 97 b.append(i + 1); 98 b.append("]="); 99 b.append(params.get(i).toString()); 100 if (i < params.size() - 1) { 101 b.append("&"); 102 } 103 } 104 return b.toString(); 76 105 } 77 106 … … 92 121 } 93 122 94 public String execute(String rpcContext, String rpcName, List params) {123 public String execute(String duz, String rpcContext, String rpcName, List params) { 95 124 if (params.size() > 0) 96 return t.rpcAs Application(this.division, "VISTALINK TESTER", rpcContext, rpcName, params);125 return t.rpcAsUser(this.division, duz, rpcContext, rpcName, params); 97 126 else 98 return t.rpcAs Application(this.division, "VISTALINK TESTER", rpcContext, rpcName);127 return t.rpcAsUser(this.division, duz, rpcContext, rpcName); 99 128 } 100 129 }
Note:
See TracChangeset
for help on using the changeset viewer.