chemaxon.jchem.db
Class RegenerationChecker

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

public class RegenerationChecker
extends java.lang.Object

Class for checking if regeneration is necessary.

Since:
JChem 5.1.3
Author:
Roland Molnar

Field Summary
static java.lang.String ATTR_ID
           
static java.lang.String ATTR_OPERATION
           
protected static java.lang.String defaultXmlFile
           
static java.lang.String OPER_EQUALS
           
static java.lang.String OPER_NOT_EQUALS
           
static java.lang.String TAG_CONDITION
           
static java.lang.String TAG_CT
           
static java.lang.String TAG_FULL
           
static java.lang.String TAG_MD
           
static java.lang.String TAG_NOCT
           
static java.lang.String TAG_PROPERTY
           
static java.lang.String TAG_PROPERTY_NAME
           
static java.lang.String TAG_PROPERTY_VALUE
           
static java.lang.String TAG_TABLE_VERSION
           
protected static org.w3c.dom.Document xml
           
protected static java.lang.String xmlName
           
 
Constructor Summary
RegenerationChecker()
           
 
Method Summary
static int deduceTableVersion(java.lang.String tableName, DatabaseProperties dp)
          Deduce a table's version from its properties and current regeneration conditions.
static int deduceTableVersion(java.lang.String tableName, DatabaseProperties dp, int regenerationType)
          Deduce a table's version from its properties and current regeneration conditions.
static java.util.List<java.lang.String> getColumnsToRegenerate(ConnectionHandler conh, java.lang.String tableName, int regenerationType)
          Return the columns should be regenerated in a table depending on a regeneration type.
static int getRegenerationTypeForTable(DatabaseProperties dp, java.lang.String tableName)
          Get which kind of regeneration is needed for a structure table.
static java.util.List<java.lang.String> getTablesToRegenerate(ConnectionHandler conh, int regenerationType)
          Give back the tables that need a type of regeneration.
static org.w3c.dom.Document getXml(java.lang.String xmlFileName)
          Read the xml file that contains the regeneration information.
static int isRegenerationNeeded(java.lang.String tableName, DatabaseProperties dp)
          Check whether any regeneration type is needed for a table.
static int isRegenerationNeeded(java.lang.String tableName, DatabaseProperties dp, org.w3c.dom.Document xml, int regenerationType)
          Check whether regeneration is needed for a table or not.
static int isRegenerationNeeded(java.lang.String tableName, DatabaseProperties dp, int regenerationType)
          Check whether regeneration is needed for a table.
static int isRegenerationNeededExact(java.lang.String tableName, DatabaseProperties dp, org.w3c.dom.Document xml, int regenerationType)
          Check whether a regeneration type is needed for a table or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xml

protected static org.w3c.dom.Document xml

xmlName

protected static java.lang.String xmlName

defaultXmlFile

protected static final java.lang.String defaultXmlFile
See Also:
Constant Field Values

TAG_TABLE_VERSION

public static final java.lang.String TAG_TABLE_VERSION
See Also:
Constant Field Values

TAG_CONDITION

public static final java.lang.String TAG_CONDITION
See Also:
Constant Field Values

TAG_PROPERTY

public static final java.lang.String TAG_PROPERTY
See Also:
Constant Field Values

TAG_PROPERTY_NAME

public static final java.lang.String TAG_PROPERTY_NAME
See Also:
Constant Field Values

TAG_PROPERTY_VALUE

public static final java.lang.String TAG_PROPERTY_VALUE
See Also:
Constant Field Values

TAG_FULL

public static final java.lang.String TAG_FULL
See Also:
Constant Field Values

TAG_CT

public static final java.lang.String TAG_CT
See Also:
Constant Field Values

TAG_NOCT

public static final java.lang.String TAG_NOCT
See Also:
Constant Field Values

TAG_MD

public static final java.lang.String TAG_MD
See Also:
Constant Field Values

ATTR_ID

public static final java.lang.String ATTR_ID
See Also:
Constant Field Values

ATTR_OPERATION

public static final java.lang.String ATTR_OPERATION
See Also:
Constant Field Values

OPER_EQUALS

public static final java.lang.String OPER_EQUALS
See Also:
Constant Field Values

OPER_NOT_EQUALS

public static final java.lang.String OPER_NOT_EQUALS
See Also:
Constant Field Values
Constructor Detail

RegenerationChecker

public RegenerationChecker()
Method Detail

getXml

public static org.w3c.dom.Document getXml(java.lang.String xmlFileName)
Read the xml file that contains the regeneration information.

Parameters:
xmlFileName - Path of the xml file that contains the regeneration rules.
Returns:
Xml document object.

isRegenerationNeeded

public static int isRegenerationNeeded(java.lang.String tableName,
                                       DatabaseProperties dp)
                                throws java.sql.SQLException
Check whether any regeneration type is needed for a table. Uses default rules.

Parameters:
tableName - Name of the table to be checked.
dp - DatabaseProperties object.
Returns:
If table version is newer older or match the JChem version.
Throws:
java.sql.SQLException

isRegenerationNeeded

public static int isRegenerationNeeded(java.lang.String tableName,
                                       DatabaseProperties dp,
                                       int regenerationType)
                                throws java.sql.SQLException
Check whether regeneration is needed for a table. Uses default rules.

Parameters:
tableName - Name of the table to be checked.
dp - DatabaseProperties object.
regenerationType - Regeneration type defined in RegenerationConstants.
Returns:
If table version is newer older or match the JChem version.
Throws:
java.sql.SQLException

isRegenerationNeeded

public static int isRegenerationNeeded(java.lang.String tableName,
                                       DatabaseProperties dp,
                                       org.w3c.dom.Document xml,
                                       int regenerationType)
                                throws java.sql.SQLException
Check whether regeneration is needed for a table or not. Uses a custom xml document which defines the regeneration rules.

Parameters:
tableName - Name of the table to be checked.
dp - DatabaseProperties object.
xml - Xml Document object.
regenerationType - Regeneration type defined in RegenerationConstants.
Returns:
If table version is newer older or match the JChem version.
Throws:
java.sql.SQLException

isRegenerationNeededExact

public static int isRegenerationNeededExact(java.lang.String tableName,
                                            DatabaseProperties dp,
                                            org.w3c.dom.Document xml,
                                            int regenerationType)
                                     throws java.sql.SQLException
Check whether a regeneration type is needed for a table or not. Searches for one specific tag in the xml and does not calculate with dependencies between regeneration types, e.g. CT regeneration + Without CT regeneration = Full regeneration

Parameters:
tableName - Name of the table to be checked.
dp - DatabaseProperties object.
xml - Xml Document object.
regenerationType - Regeneration type defined in RegenerationConstants.
Returns:
If table version is newer older or match the JChem version.
Throws:
java.sql.SQLException

deduceTableVersion

public static int deduceTableVersion(java.lang.String tableName,
                                     DatabaseProperties dp)
                              throws java.sql.SQLException
Deduce a table's version from its properties and current regeneration conditions.

Parameters:
tableName - Name of the structure table
dp - Database Properties object.
Returns:
The table version.
Throws:
java.sql.SQLException

deduceTableVersion

public static int deduceTableVersion(java.lang.String tableName,
                                     DatabaseProperties dp,
                                     int regenerationType)
                              throws java.sql.SQLException
Deduce a table's version from its properties and current regeneration conditions.

Parameters:
tableName - Name of the structure table
dp - Database Properties object.
regenerationType - Regeneration type defined in RegenerationConstants.
Returns:
The table version.
Throws:
java.sql.SQLException

getTablesToRegenerate

public static java.util.List<java.lang.String> getTablesToRegenerate(ConnectionHandler conh,
                                                                     int regenerationType)
                                                              throws java.sql.SQLException
Give back the tables that need a type of regeneration.

Parameters:
conh - Connection handler.
regenerationType - Regeneration type defined in RegenerationConstants.
Returns:
List of table names that need to be regenerated.
Throws:
java.sql.SQLException

getRegenerationTypeForTable

public static int getRegenerationTypeForTable(DatabaseProperties dp,
                                              java.lang.String tableName)
                                       throws java.sql.SQLException
Get which kind of regeneration is needed for a structure table.

Parameters:
dp - DatabaseProperties object.
tableName - Name of the table.
Returns:
Regeneration type defined in RegenerationConstants.
Throws:
java.sql.SQLException

getColumnsToRegenerate

public static java.util.List<java.lang.String> getColumnsToRegenerate(ConnectionHandler conh,
                                                                      java.lang.String tableName,
                                                                      int regenerationType)
                                                               throws java.sql.SQLException
Return the columns should be regenerated in a table depending on a regeneration type.

Parameters:
conh - Connection handler.
tableName - Name of the table.
regenerationType - Regeneration type defined in RegenerationConstants.
Returns:
List of table field names.
Throws:
java.sql.SQLException