UniBean

From Pickwiki
Revision as of 23:48, 26 February 2015 by Conversion script (talk) (link fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
/*
 * [[UniBean]].java
 *
 * Created on July 23, 2002, 6:14 PM
 */

import java.beans.*;
import asjava.uniobjects.*;
import asjava.uniclientlibs.*;

/**
 * This is the main container class for the Universe objects program.
 *
 * @author  William L. Terry
 * @version 0.1, 09/23/02
 */
public class [[UniBean]] extends Object implements java.io.Serializable {

    private [[UniJava]] uJava;
    private [[UniSession]] uSession = null;

    private String name = "";      // username
    private String password = "";  // password
    private String host = "";      // the FQDN of the host we are conneting to.
    private String account = "";   // The full path to the account directory.

    private String alive = "no";

    private String patientName;

    /** Creates new [[UniBean]] */
    public [[UniBean]]()  {
    }

    /**  Creates the [[UniJava]] and Unisession objects for use
     *
     * @throws [[UniSessionException]] _
     */
    public void init() throws [[UniSessionException]] {
        uJava = new [[UniJava]]();
        uSession = uJava.openSession();
    }

    /**  This is a test
     *
     * @return the results of "LIST VOC SAMPLE 10" */
    public String getTest() {
        String rs1 = "";
        String returnString = "";

        try {
            [[UniCommand]] uvc = uSession.command();
            uvc.setCommand("LIST VOC SAMPLE 10");
            uvc.exec();
            returnString = uvc.response();
        }
        catch ([[UniCommandException]] e) {
            returnString = "Error: " + e;
        }
        catch ([[UniSessionException]] e) {
            returnString = "Error: " + e;
        }
        return returnString;
    }

    /** Logout of the database.
     * @throws [[UniSessionException]] _
     */
    public void logout() throws [[UniSessionException]] {
        uSession.disconnect();
    }

    /** Logs in and connects to the database.
     *
     * @param aName A user logon name.
     * @param aPassword The users password.
     * @param aHost The FQDN of database host.
     * @param aAccount The filepath to database
     * @throws [[UniSessionException]] _
     */
    public void logon(String aName,
                      String aPassword,
                      String aHost,
                      String aAccount) throws [[UniSessionException]] {

        name = aName;
        password = aPassword;
        host = aHost;
        account = aAccount;

        uSession.connect(host, name, password, account);
        alive = "yes";
    }

    /**
     * Returns the [[UniSession]] object
     *
     * @return A [[UniSession]] object
     */
    public [[UniSession]] get[[UniSession]]() {
        return uSession;
    }

    /** Gets the username and database of the account connected
     * @return the username and database for the connection.
     */
    public String get[[AccountPath]]() {
        String accountPath = "NOT LOGGED IN";
        try {
            String atVar1 = uSession.get[[AtVariable]](1);
            String atVar4 = uSession.get[[AtVariable]](4);
            accountPath = "[" + atVar1 + " - " + atVar4 + "]";
        }
        catch ([[UniSessionException]] e) {
        }
        return accountPath;
    }

    /** Checks the uSession to see that it is connected
     * @return True is the usession is connected.
     */
    public boolean isActive() {
        return uSession.isActive();
    }

    /** Returns the flag identifying if the system is alive (connected)
     * @return True is alive (connectea)d.
     */
    public String getAlive() {
        return alive;
    }

}