org.ifeth.sehr.client.api
Class SEHRRemote

java.lang.Object
  extended byorg.ifeth.sehr.client.api.SEHRRemote
All Implemented Interfaces:
ConnectionListener, SEHRConnectionDriverInterface, SEHRRemoteInterface
Direct Known Subclasses:
SessionHandler

public class SEHRRemote
extends java.lang.Object
implements SEHRRemoteInterface, SEHRConnectionDriverInterface, ConnectionListener

This is the basic layer to connect a GUI client by LAN or WAN to a SEHR host (server).

WEB based SEHR applications are based on servlets and running on the same machine (host) as the SEHR service. So the serverside components do have physical (file) access to the configuration of a SEHR server.
External (GUI) applications running on remote clients can not simply read the configuration file on the host to retrieve settings for accessing e.g. the mailservice, zone and medical databases.
This remote object therefore binds, connects and get the settings for external clients.
Requirements and Connection:

  • Figure out the IP and port of the SEHR host; these are the only parameters required on startup
  • bindSEHRServer(String, int, int)
    Method to bind the client to the SEHR host. At this point there is no physical layer/connection required (like a RAS connection) but the type of driver to use must be given and will be loaded.
  • connect()
    Establish a socket connection to the SEHR server
  • It will be a useful practice to store the IP and port in a local configuration file or batchfile as commandline parameters. In this case no inside coding is required to connect a SEHR server. Once bind and connected use getter methods to receive the SEHR host configuration. Use some of the use-case methods to shorten up your coding, e.g. for user authentication use login2service(int, String, String, String).

    Author:
    hansjhaase, jreynolds
    See Also:
    SEHRConnectionDriverInterface, SEHRConnectionDriver

    Field Summary
    static java.util.logging.Logger Log
               
     
    Fields inherited from interface org.ifeth.sehr.client.api.SEHRRemoteInterface
    DBPORT, DBUSER, DBUSERPASS, SEHRHOST, sehrkeyphrase, SEHRPORT
     
    Fields inherited from interface org.ifeth.sehr.client.api.SEHRConnectionDriverInterface
    COSTCONTROL_NONE, COSTCONTROL_TIME, COSTCONTROL_VOLUME, DRV_ASYNC, DRV_LAN, DRV_RAS, TYPE_ASYNC, TYPE_LAN, TYPE_RAS, TYPE_WLAN
     
    Constructor Summary
    SEHRRemote()
              Parameterless constructor.
    SEHRRemote(java.lang.String ip, int port)
              Constructor binding the client to a SEHR server using given IP and port by using the LAN driver (for LAN and permanent WAN connections)
    SEHRRemote(java.lang.String ip, int port, int typeofdriver)
              Constructor binding the client to a SEHR server using IP, port and given SEHR driver
    SEHRRemote(java.lang.String ip, int port, java.lang.String driverclass)
              Constructor binding the client to a SEHR server using given IP, Port and SEHR compatible driver as named class
     
    Method Summary
     void bindSEHRServer(java.lang.String ip, int port)
              This method binds a client to a SEHR server using the LAN connection driver.
     void bindSEHRServer(java.lang.String ip, int port, int contype)
              This method binds a client to a SEHR server using one of the implemented drivers depending on the type of connection.
     void bindSEHRServer(java.lang.String ip, int port, java.lang.String driverclass)
              This method binds a client to a SEHR server using the given driver class to establish the physical connection Note:
    No physical IP connection is required at this point.
    static boolean CheckSEHRHostConnection(java.lang.String ip, int port, java.lang.String drv)
              Static method to check if a SEHR host is available for requests.
     boolean connect()
              This method establishes the connection between the client and the SEHR host.
     boolean connect(boolean keepalive)
              This method establishes a socket connection to the SEHR host and loads the SEHR host settings
     java.sql.Connection connectIntraSEC()
              Establish a connection to the zone database IntraSEC of a SEHR host.
     void connectionChanged(SEHRConnection c)
              Notifies the listener that a connection status has changed, e.g. from 'used' to 'unused'.
     void connectionClosed(SEHRConnection c)
              Notifies the listener that a connection is closed and going to be discarded.
     void connectionOpen(SEHRConnection c)
              Notifies the listener that a connection is new or open.
     void disconnect()
              Disconnects the physical transport layer (#0) Use this to cut the connection on expensive lines.
     double disconnect(int layer)
              Disconnects the given connection layer
     ConnectionInfo getConinfo()
              Returns information object about the physical connection (layer 0)
     java.util.Vector getConnectionLayers()
              (Vector-)List of ConnectionInfo objects Each ConnectionInfoobject represents a connection layer including the object with id '0', the physical connection to a SEHR host.
     java.lang.Object getConnectionObject(int layer)
               
     int getConnectionStatus()
              Returns the current connection status of the physical layer of the driver interface.
     int getConnectionTimeOut()
              For informational usage: get current sec to wait for a C/S connection
     double getCurrentDuration()
              Returns elapsed time of physical layer(0); this represents the remote connection itself
     double getCurrentDuration(int layer)
              Returns elapsed time of a given layer(0); this represents e.g. a db connection on top of the pysical connection
     ConnectionDriver getDriver()
              Get driver object used for the c/s connection
     java.util.logging.Logger getLog()
               
     SEHRConnection getSEHRconnection(int idx)
              Returns the SEHRconnection layer of the remote object for a given index
     java.util.Hashtable getSEHRHostProperties()
              Get the received server settings as Hashtable
     java.lang.String getSEHRServerIP()
               
     int getSEHRServerPort()
               
     double getTotalConnectionTime(int layer)
               
     SEHRDataSource initSEHRDataSource()
              Initialize a new SEHRDataSource object on the SEHR host connection Use this to access a db on SEHR host e.g. by 'Java.sql' objects, DAOJdbc.DAOJdbc(SEHRDataSource)or other layers.
     boolean isConnected()
               
    static boolean isNULLOrEmpty(java.lang.String s)
              Check if a string is null or empty.
     boolean isSEHRService()
              'true' if a (previous) connection was established successfully To test only if a connection can be established use static method CheckSEHRHostConnection(String, int, String) and give IP and port as parameters.
     int login2service(int usrid, java.lang.String login, java.lang.String pw, java.lang.String pik)
              Simple login wrapper for checking user access against a SEHR service.
     int login2zone(java.lang.String usrname, java.lang.String pw, java.lang.String zoneid)
              Simple login wrapper for checking user against a SEHR zone.
    static void main(java.lang.String[] args)
              For testing purposes this class should be executed within the workspace Eclipse.
     boolean reconnect()
               
     void setConnectionTimeOut(int msecs)
              Set timeout in msecs to establish a connection (listensocket);
     void setDriver(ConnectionDriver driver)
              Redefine or set an already defined driver to use for the c/s connection
     void setLog(java.util.logging.Logger log)
               
     void setRASEntry(java.lang.String entry)
              Set the RAS entry to dial
     void setRASPassword(java.lang.String pw)
              Set the user's password to login at SEHR host
     void setRASUsername(java.lang.String username)
              Set the user to login at SEHR host, e.g. for a RAS connection
     void setSEHRHostProperties(java.util.Hashtable sp)
               
     void setSEHRServerIP(java.lang.String serverip)
               
     void setSEHRServerPort(int serverport)
               
     void setSEHRService(boolean isSEHRService)
               
    static java.lang.String trimNULL(java.lang.String s)
              Helper method to set 'null' strings to "" strings for a better review from database.
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    Log

    public static java.util.logging.Logger Log
    Constructor Detail

    SEHRRemote

    public SEHRRemote()
    Parameterless constructor. To init/bind the remote object to a SEHR host use bindSEHRServer(String, int)


    SEHRRemote

    public SEHRRemote(java.lang.String ip,
                      int port)
    Constructor binding the client to a SEHR server using given IP and port by using the LAN driver (for LAN and permanent WAN connections)


    SEHRRemote

    public SEHRRemote(java.lang.String ip,
                      int port,
                      int typeofdriver)
    Constructor binding the client to a SEHR server using IP, port and given SEHR driver


    SEHRRemote

    public SEHRRemote(java.lang.String ip,
                      int port,
                      java.lang.String driverclass)
    Constructor binding the client to a SEHR server using given IP, Port and SEHR compatible driver as named class

    Method Detail

    isNULLOrEmpty

    public static boolean isNULLOrEmpty(java.lang.String s)
    Check if a string is null or empty.

    Note: The method is static so it can be used by other classes :)


    trimNULL

    public static java.lang.String trimNULL(java.lang.String s)
    Helper method to set 'null' strings to "" strings for a better review from database. If string is not null the string itself is returned trimmed.

    Note: The method is static so it can be used by other classes :)

    Returns:
    string

    bindSEHRServer

    public void bindSEHRServer(java.lang.String ip,
                               int port,
                               int contype)
    This method binds a client to a SEHR server using one of the implemented drivers depending on the type of connection.

    Note:
    No physical IP connection is required at this point. This method just initialize the remote object for connections to the given SEHR host by loading the driver and setting the connection params.

    Specified by:
    bindSEHRServer in interface SEHRRemoteInterface
    Parameters:
    ip - IP of SEHR host connect to
    port - Port of SEHR service on host

    bindSEHRServer

    public void bindSEHRServer(java.lang.String ip,
                               int port,
                               java.lang.String driverclass)
    This method binds a client to a SEHR server using the given driver class to establish the physical connection

    Note:
    No physical IP connection is required at this point. This method just initialize the remote object for connections to the given SEHR host by loading the driver and setting the params.

    Specified by:
    bindSEHRServer in interface SEHRRemoteInterface
    Parameters:
    ip - IP of SEHR host connect to
    port - Port of SEHR service on host

    bindSEHRServer

    public void bindSEHRServer(java.lang.String ip,
                               int port)
    This method binds a client to a SEHR server using the LAN connection driver.

    Note:
    No physical IP connection is started at this point. This method just initialize the remote object for connections to the given SEHR host by LAN.

    Specified by:
    bindSEHRServer in interface SEHRRemoteInterface
    Parameters:
    ip - IP of SEHR host connect to
    port - Port of SEHR service on host

    connect

    public boolean connect()
    This method establishes the connection between the client and the SEHR host.

    Note: A physical IP connection will be established by this method.

    Specified by:
    connect in interface SEHRRemoteInterface

    connect

    public boolean connect(boolean keepalive)
    This method establishes a socket connection to the SEHR host and loads the SEHR host settings


    reconnect

    public boolean reconnect()

    isConnected

    public boolean isConnected()

    disconnect

    public void disconnect()
    Disconnects the physical transport layer (#0)

    Use this to cut the connection on expensive lines.
    Note:
    The field isSEHRService remain unchanged to keep the last status of SEHR host connection.


    disconnect

    public double disconnect(int layer)
    Disconnects the given connection layer


    getConnectionLayers

    public java.util.Vector getConnectionLayers()
    (Vector-)List of ConnectionInfo objects

    Each ConnectionInfoobject represents a connection layer including the object with id '0', the physical connection to a SEHR host.
    A client connection manager should iterate frequently through the list to check if a data handler tells that a connection is not required any longer ( closeRequest==true ). On this flag the handler should check if there is sth. to do left and then free the connection by setting the status to 0 (setStatud(0) ). The build in remote cleaner then will remove the conenction the next time he arrives on it.


    getCurrentDuration

    public double getCurrentDuration()
    Returns elapsed time of physical layer(0); this represents the remote connection itself


    getCurrentDuration

    public double getCurrentDuration(int layer)
    Returns elapsed time of a given layer(0); this represents e.g. a db connection on top of the pysical connection


    getConnectionObject

    public java.lang.Object getConnectionObject(int layer)

    getConnectionStatus

    public int getConnectionStatus()
    Returns the current connection status of the physical layer of the driver interface. The driver interface contains a thread that monitors the connection and notifies the connection listeners.

    For the status codes see ConnectionConstants


    getTotalConnectionTime

    public double getTotalConnectionTime(int layer)

    connectionOpen

    public void connectionOpen(SEHRConnection c)
    Description copied from interface: ConnectionListener
    Notifies the listener that a connection is new or open.

    Specified by:
    connectionOpen in interface ConnectionListener

    connectionClosed

    public void connectionClosed(SEHRConnection c)
    Description copied from interface: ConnectionListener
    Notifies the listener that a connection is closed and going to be discarded.

    Specified by:
    connectionClosed in interface ConnectionListener

    connectionChanged

    public void connectionChanged(SEHRConnection c)
    Description copied from interface: ConnectionListener
    Notifies the listener that a connection status has changed, e.g. from 'used' to 'unused'.

    Specified by:
    connectionChanged in interface ConnectionListener

    getSEHRHostProperties

    public java.util.Hashtable getSEHRHostProperties()
    Get the received server settings as Hashtable

    See Also:
    connect(boolean)

    setSEHRHostProperties

    public void setSEHRHostProperties(java.util.Hashtable sp)

    initSEHRDataSource

    public SEHRDataSource initSEHRDataSource()
    Initialize a new SEHRDataSource object on the SEHR host connection

    Use this to access a db on SEHR host e.g. by 'Java.sql' objects, DAOJdbc.DAOJdbc(SEHRDataSource)or other layers.
    Note: A physical db connection is not required at this point.

    Specified by:
    initSEHRDataSource in interface SEHRRemoteInterface

    connectIntraSEC

    public java.sql.Connection connectIntraSEC()
    Establish a connection to the zone database IntraSEC of a SEHR host.

    Note: This method is not required if DAOJdbc is used.


    login2service

    public int login2service(int usrid,
                             java.lang.String login,
                             java.lang.String pw,
                             java.lang.String pik)
    Simple login wrapper for checking user access against a SEHR service.

    To get the names and PIK of modules use SEHRModules.listModules(). For example build a menu to let the user select a service, then get the PIK from vector list and check with this method if user is allowed to use the service.


    login2zone

    public int login2zone(java.lang.String usrname,
                          java.lang.String pw,
                          java.lang.String zoneid)
    Simple login wrapper for checking user against a SEHR zone.

    The current zoneid is read by getSEHRHostProperties().


    CheckSEHRHostConnection

    public static boolean CheckSEHRHostConnection(java.lang.String ip,
                                                  int port,
                                                  java.lang.String drv)
    Static method to check if a SEHR host is available for requests.

    Note: This method connects to a SEHR host using the given driver class.

    Parameters:
    port - port to connect on host; 'int' value >1024 (otherwise 24100 is set)
    Returns:
    true/false 'true' if a connection could be established

    getSEHRServerIP

    public java.lang.String getSEHRServerIP()

    setSEHRServerIP

    public void setSEHRServerIP(java.lang.String serverip)

    getSEHRServerPort

    public int getSEHRServerPort()

    setSEHRServerPort

    public void setSEHRServerPort(int serverport)

    getDriver

    public ConnectionDriver getDriver()
    Get driver object used for the c/s connection

    Returns:
    driver_object 'null' if no driver assigned

    setDriver

    public void setDriver(ConnectionDriver driver)
    Redefine or set an already defined driver to use for the c/s connection


    getConinfo

    public ConnectionInfo getConinfo()
    Returns information object about the physical connection (layer 0)


    getSEHRconnection

    public SEHRConnection getSEHRconnection(int idx)
    Returns the SEHRconnection layer of the remote object for a given index


    isSEHRService

    public boolean isSEHRService()
    'true' if a (previous) connection was established successfully

    To test only if a connection can be established use static method CheckSEHRHostConnection(String, int, String) and give IP and port as parameters.


    setSEHRService

    public void setSEHRService(boolean isSEHRService)

    setRASEntry

    public void setRASEntry(java.lang.String entry)
    Set the RAS entry to dial


    setRASUsername

    public void setRASUsername(java.lang.String username)
    Set the user to login at SEHR host, e.g. for a RAS connection


    setRASPassword

    public void setRASPassword(java.lang.String pw)
    Set the user's password to login at SEHR host


    getConnectionTimeOut

    public int getConnectionTimeOut()
    For informational usage: get current sec to wait for a C/S connection


    setConnectionTimeOut

    public void setConnectionTimeOut(int msecs)
    Set timeout in msecs to establish a connection (listensocket);


    getLog

    public java.util.logging.Logger getLog()

    setLog

    public void setLog(java.util.logging.Logger log)

    main

    public static void main(java.lang.String[] args)
    For testing purposes this class should be executed within the workspace Eclipse.

    Instruction:

  • To test the module get a valid IP/Port pair of a running SEHR server and modify parameters below
  • Run this module