chemaxon.jchem.db
Class Updater

java.lang.Object
  extended by chemaxon.jchem.db.Updater

public class Updater
extends java.lang.Object

Class for upgrading JChem database structure. Usage example:

 String message = "";
 ProgressWriter pw = ...;
 Updater ud = new Updater(conh);
 Updater.UpdateInfo ui = null;
 while ((ui = ud.getNextUpdateInfo()) != null) {
     if (displayMessage(ui)) {
        System.out.println("\n" + ui.processingMessage + "\n");
          if (ui.isProgressMonitoringSupported) {
            message = ud.performCurrentUpdate(pw);
        } else {
            message = ud.performCurrentUpdate();
        }
        System.out.println(message);
    } else if (ui.isOperationRequired) {
          // stopping, since further updates may depend on this one
          break;
    }
}
 

Since:
JChem 3.2
Author:
Szilard Dorant, Roland Molnar, Peter Kovacs (pkovacs84)

Nested Class Summary
 class Updater.UpdateInfo
          Class describing the nature of an update.
 
Constructor Summary
Updater(ConnectionHandler conh)
          Constructor.
Updater(ConnectionHandler conh, java.util.List<java.lang.String> tablesToConsider)
          Similar to Updater(ConnectionHandler), but adds the ability for the user to specify a list of tables to which to restrict the operation of this Updater.
 
Method Summary
 Updater.UpdateInfo getNextUpdateInfo()
          Returns the update information for the next update step.
 boolean isUpdateNeededForTable(java.lang.String tableName)
          Check whether structural upgrade is necessary for a particular table.
 java.lang.String performCurrentUpdate()
          Performs the current update operation.
 java.lang.String performCurrentUpdate(ProgressWriter pw)
          Performs the current update operation with progress monitoring where supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Updater

public Updater(ConnectionHandler conh)
Constructor.

Parameters:
conh - ConnectionHandler with live connection
Since:
JChem 3.2

Updater

public Updater(ConnectionHandler conh,
               java.util.List<java.lang.String> tablesToConsider)
Similar to Updater(ConnectionHandler), but adds the ability for the user to specify a list of tables to which to restrict the operation of this Updater.

Parameters:
conh - ConnectionHandler with live connection
tablesToConsider - include only these tables in the update.
Since:
JChem 3.2
Method Detail

getNextUpdateInfo

public Updater.UpdateInfo getNextUpdateInfo()
                                     throws java.sql.SQLException
Returns the update information for the next update step.

Returns:
the message, or null, if there are no more updates left
Throws:
java.sql.SQLException
See Also:
performCurrentUpdate()

isUpdateNeededForTable

public boolean isUpdateNeededForTable(java.lang.String tableName)
                               throws java.sql.SQLException
Check whether structural upgrade is necessary for a particular table.

Parameters:
tableName - Name of the structure table.
Returns:
True, if upgrade is needed.
Throws:
java.sql.SQLException

performCurrentUpdate

public java.lang.String performCurrentUpdate()
                                      throws java.sql.SQLException
Performs the current update operation.

Throws:
java.sql.SQLException
See Also:
getNextUpdateInfo()

performCurrentUpdate

public java.lang.String performCurrentUpdate(ProgressWriter pw)
                                      throws java.sql.SQLException
Performs the current update operation with progress monitoring where supported.

Throws:
java.sql.SQLException
Since:
JChem 5.1.2
See Also:
getNextUpdateInfo()