suncertify.client
Class QueryInterfaceWrapper

java.lang.Object
  |
  +--suncertify.client.QueryInterfaceWrapper
All Implemented Interfaces:
LoggerSupport

public class QueryInterfaceWrapper
extends java.lang.Object
implements LoggerSupport

The Class is responsible for database access. It may work in two modes ALONE and CLIENT that is local and remote respectively. It hides all detail like poping-up information window, exception and error handling so it allows for easy data base operation excution from the client GUI. As db access methods may hung (e.g. lock, update as far as remote invocations) they are executed in a new thread (see concreat method descrition for details).

LoggerSupport, in local mode the QueryInterfaceImpl class requires the log method to log dataBase events, it is not used in remote version as the server logs database events


Field Summary
static int ALONE
          one of the possible working mode - the local one
static int CLIENT
          one of the possible working mode - the remote one
 
Constructor Summary
QueryInterfaceWrapper(int mode, javax.swing.JFrame frame)
          The constructor inicialize the QueryInterfaceWrapper instance with mode to work in (local or remote), a reference to the parent frame object is also required for pop-ups window.
 
Method Summary
 boolean checkConnected()
           
 void create(java.lang.String[] data)
          Asynchronous create invocation.
 boolean dbConnect()
          Method establishe the connection with dataBase..
 void dbDisconnect()
          Disconnect from the database.
 void delete(int recordId)
          Asynchronous delete invocation.
 int[] find(java.lang.String[] criteria)
          Synchronous find method.
 void isLocked(int recordId)
          Asynchronous isLocked method invocation.
 void lock(int recordId)
          Asynchronous lock method invocation.
 void log(java.lang.String text)
          Log method requierd buy the LoggableInterface, in local mode the QueryInterfaceImpl class requires the log method to log dataBase events, it is not used in remote version as server logs database events
 java.lang.String[] read(int rowId)
          Synchronous read method.
 void unlock(int recordId)
          Asynchronous unlock method invocation.
 void update(int rowId, java.lang.String[] data)
          Asynchronous update invocation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALONE

public static final int ALONE
one of the possible working mode - the local one

See Also:
Constant Field Values

CLIENT

public static final int CLIENT
one of the possible working mode - the remote one

See Also:
Constant Field Values
Constructor Detail

QueryInterfaceWrapper

public QueryInterfaceWrapper(int mode,
                             javax.swing.JFrame frame)
The constructor inicialize the QueryInterfaceWrapper instance with mode to work in (local or remote), a reference to the parent frame object is also required for pop-ups window.

Parameters:
mode - - the mode in which intance is supposed to work
frame - - reference to the main fram of the application
Method Detail

dbConnect

public boolean dbConnect()
Method establishe the connection with dataBase.. According to the value of mode attribute the local dataBase is opend (QueryInterfaceImpl) or a remote connection is made (QueryInterface is narrowed to the remote Object. Appriopriate connections details (fileName or ServerName, RegistryPort number and optional LoginName is take from PropertiesWrapper object for each mode respectively)

Returns:
true if connection succeed false elseway
See Also:
QueryInterface.logIn(String), QueryInterface.logIn()

dbDisconnect

public void dbDisconnect()
Disconnect from the database. For the local mode the database fiel is close for the remote version client is logged out and reference to the remote object is dropped;

See Also:
QueryInterface.logOut(String), QueryInterfaceImpl.closeDB()

find

public int[] find(java.lang.String[] criteria)
Synchronous find method. It calls find method on QueryInterface. If any error/exception occures the appriopriate messageBox is displayed and null is returned

Parameters:
criteria - the search criteria
Returns:
array of indexes of records muching the criteria
See Also:
QueryInterface.find(String[], String)

read

public java.lang.String[] read(int rowId)
Synchronous read method. It calls read method on QueryInterface. If any error/exception occures the appriopriate messageBox is displayed and null is returned

Parameters:
rowId - the id of requested record
Returns:
array of String that are the data of specified record
See Also:
QueryInterface.read(int, String)

delete

public void delete(int recordId)
Asynchronous delete invocation. The information dialog is displayed, new thread is created and method invocation is done by it. if it finishes the method execution (may be remote depending of mode) the message in the box is changed informing about success or fail and user may close the window. If any error/exception occures the appriopriate messageBox is displayed.

Parameters:
recordId - the id of record to delete
See Also:
QueryInterface.delete(int, String)

update

public void update(int rowId,
                   java.lang.String[] data)
Asynchronous update invocation. The information dialog is displayed, new thread is created and method invocation is done by it. if it finishes the method execution (may be remote depending of mode) the message in the box is changed informing about success or fail and user may close the window. If any error/exception occures the appriopriate messageBox is displayed.

Parameters:
data - new data for the record
See Also:
QueryInterface.update(int, String[], String)

create

public void create(java.lang.String[] data)
Asynchronous create invocation. The information dialog is displayed, new thread is created and method invocation is done by it. if it finishes the method execution (may be remote depending of mode) the message in the box is changed informing about success or fail and user may close the window. If any error/exception occures the appriopriate messageBox is displayed.

Parameters:
data - data for the new record
See Also:
QueryInterface.create(String[], String)

isLocked

public void isLocked(int recordId)
Asynchronous isLocked method invocation. The information dialog is displayed, new thread is created and method invocation is done by it. if it finishes the method execution (may be remote depending of mode) the message in the box is changed informing about the record state. If any error/exception occures the appriopriate messageBox is displayed.

Parameters:
recordId - the id of record to ask for
See Also:
QueryInterface.isLocked(int, String)

lock

public void lock(int recordId)
Asynchronous lock method invocation. The information dialog is displayed, new thread is created and method invocation is done by it. if it finishes the method execution (may be remote depending of mode) the message in the box is changed informing about success or fail and user may close the window. If any error/exception occures the appriopriate messageBox is displayed.

Parameters:
recordId - the id of record to ask for
See Also:
QueryInterface.lock(int, String)

unlock

public void unlock(int recordId)
Asynchronous unlock method invocation. The information dialog is displayed, new thread is created and method invocation is done by it. if it finishes the method execution (may be remote depending of mode) the message in the box is changed informing about success or fail and user may close the window. If any error/exception occures the appriopriate messageBox is displayed.

Parameters:
recordId - the id of record to ask for
See Also:
QueryInterface.unlock(int, String)

checkConnected

public boolean checkConnected()

log

public void log(java.lang.String text)
Log method requierd buy the LoggableInterface, in local mode the QueryInterfaceImpl class requires the log method to log dataBase events, it is not used in remote version as server logs database events

Specified by:
log in interface LoggerSupport
Parameters:
text - to be logged