initial commit of command-line vistalink-tester

This commit is contained in:
sblaz 2011-10-13 06:47:16 +00:00
parent e1efd987ae
commit 83a7255b2e
2 changed files with 227 additions and 0 deletions

View File

@ -0,0 +1,127 @@
<?xml version="1.0"?>
<!-- -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gov.va.med.edp</groupId>
<artifactId>vistalink-tester</artifactId>
<packaging>jar</packaging>
<name>VistALink Tester Application</name>
<version>0.1</version>
<description>Emergency Department Integration Software - Tracking Server Application</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-support</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>gov.va.med.edp</groupId>
<artifactId>edis-tracking-server-vista</artifactId>
<version>1.0.1.WorldVistA-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
<version>4.0-beta1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<target>1.6</target>
<source>1.6</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>gov.va.med.edp.VistaLinkTester</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<!-- Optional -->
<onejarVersion>0.97</onejarVersion>
<classifier></classifier>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>onejar-maven-plugin.googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- versions of dependencies -->
<spring.version>2.5.6</spring.version>
<spring.security.version>2.0.7.RELEASE</spring.security.version>
<slf4j.version>1.6.2</slf4j.version>
</properties>
</project>

View File

@ -0,0 +1,100 @@
package gov.va.med.edp;
import gov.va.med.edp.vistalink.VistaLinkTemplate;
import gov.va.med.edp.vistalink.locator.VistaLinkConnectorConfig;
import gov.va.med.edp.vistalink.locator.VistaLinkConnectorConfigConnectionFactoryLocator;
import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import java.io.Console;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import static java.util.Arrays.asList;
public class VistaLinkTester {
public static void main(String[] args) throws IOException {
OptionParser parser = new OptionParser();
OptionSpec<String> hostOption = parser.acceptsAll(asList("S", "server", "host")).withRequiredArg().ofType(String.class);
OptionSpec<Integer> portOption = parser.acceptsAll(asList("P", "port")).withRequiredArg().ofType(Integer.class);
OptionSpec<String> divisionOption = parser.acceptsAll(asList("D", "division", "station-num")).withRequiredArg().ofType(String.class);
OptionSpec<String> rpcContextOption = parser.acceptsAll(asList("C", "context", "rpc-context")).withRequiredArg().ofType(String.class);
OptionSpec<String> rpcNameOption = parser.acceptsAll(asList("N", "name", "rpc-name")).withRequiredArg().ofType(String.class);
try {
OptionSet options = parser.parse(args);
Console console = System.console();
String host = options.has(hostOption) ? hostOption.value(options) : console.readLine("Host: ");
int port = options.has(portOption) ? portOption.value(options) : Integer.parseInt(console.readLine("Port: "));
String division = options.has(divisionOption) ? divisionOption.value(options) : console.readLine("Division: ");
char[] accessCode = console.readPassword("Access: ");
char[] verifyCode = console.readPassword("Verify: ");
String rpcContext = options.has(rpcContextOption) ? rpcContextOption.value(options) : console.readLine("RPC Context: ");
String rpcName = options.has(rpcNameOption) ? rpcNameOption.value(options) : console.readLine("RPC Name: ");
;
if (rpcContext == null) rpcContext = "";
VistaLinkTester tester = new VistaLinkTester(host, port, division, accessCode.toString(), verifyCode.toString());
System.out.println("Enter RPC Parameters (^ when finished)");
List<String> params = new ArrayList<String>();
int i = 1;
boolean done = false;
while (!done) {
String param = console.readLine("RPC Param " + i + ": ");
if (param.equalsIgnoreCase("^")) {
done = true;
} else {
params.add(param);
i++;
}
}
System.out.println("Executing vlink://" + division + "@" + host + ":" + port + "/" + rpcContext + "/" + rpcName);
System.out.println(tester.execute(rpcContext, rpcName, params));
} catch (OptionException e) {
System.out.println(e.getLocalizedMessage());
System.out.println("Usage:");
parser.printHelpOn(System.out);
System.exit(1);
} catch (Throwable t) {
t.printStackTrace();
}
// HashSet connectors = new HashSet();
// connectors.add(new VistaLinkConnectorConfig("500", "WORLDVISTA DEMO CLINIC", "66.206.177.84", 9310, "EDISUSER1", "VISTAIS#1"));
}
private String division;
private VistaLinkTemplate t;
public VistaLinkTester(String host, int port, String division, String accessCode, String verifyCode) {
this.division = division;
HashSet connectors = new HashSet();
connectors.add(new VistaLinkConnectorConfig(division, "VISTALINK TESTER", host, port, accessCode, verifyCode));
VistaLinkConnectorConfigConnectionFactoryLocator l = new VistaLinkConnectorConfigConnectionFactoryLocator();
l.setConnectors(connectors);
t = new VistaLinkTemplate(l);
}
public String execute(String rpcContext, String rpcName, List params) {
if (params.size() > 0)
return t.rpcAsApplication(this.division, "VISTALINK TESTER", rpcContext, rpcName, params);
else
return t.rpcAsApplication(this.division, "VISTALINK TESTER", rpcContext, rpcName);
}
}