Class DatabaseProperties

  • All Implemented Interfaces:
    TableTypeConstants

    @PublicAPI
    public class DatabaseProperties
    extends Object
    implements TableTypeConstants
    Methods for reading and writing the JChemProperties table that contains information about the database and the structure tables. The content of the JChemProperties table informs JChem how to

    The table has 3 columns:

    Property table contents
    prop_name Key column (stores the name of each property which is used as a unique key).
    prop_value. Basic value column (short values are stored here).
    prop_value_ext. Extended value column (large values are stored here).

    • Constructor Detail

      • DatabaseProperties

        public DatabaseProperties​(ConnectionHandler conh,
                                  boolean indexTable)
                           throws SQLException
        Constructs an instance for use with JChem structure tables or JChem Cartridge index tables.
        Parameters:
        conh - the ConnectionHandler object that contains at least a valid JDBC connection and property table name.
        indexTable - true if this instance is to be used with JChem Cartridge index tables, false in case of JChem structure tables.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        JChem 5.0
    • Method Detail

      • getPropertyTableName

        public String getPropertyTableName()
        Return the name of the JChem properties table.
        Returns:
        the name of the JChem properties table
        Since:
        JChem 5.12
      • getProperty

        public String getProperty​(String name)
                           throws SQLException
        Searches for the property with the specified key in the JChemProperties table. If value is null, returns the extended value.
        Parameters:
        name - the property key.
        Returns:
        the value in this property list with the specified key value, or null if the property doesn't exist.
        Throws:
        SQLException - if encounter an sql exception
      • getIntProperty

        public int getIntProperty​(String name)
                           throws SQLException
        Searches for the property with the specified key in the JChemProperties table.
        Parameters:
        name - the property key.
        Returns:
        the value converted to int, or Integer.MINVALUE, if not found in the table.
        Throws:
        NumberFormatException - if the property value cannot be parsed as an integer
        SQLException - if encounter an sql exception
      • addProperty

        public void addProperty​(String name,
                                String value)
                         throws SQLException
        Inserts the property with the specified key and value into the JChemProperties table. If the specified value is null, the property is deleted.
        Parameters:
        name - the property key.
        value - the property value. If null, the property is deleted.
        Throws:
        SQLException - if encounter an sql exception
      • updateProperty

        public void updateProperty​(String name,
                                   String value)
                            throws SQLException
        Updates the property with the specified key and value in the JChemProperties table. If the specified value is null, the property is deleted.
        Parameters:
        name - the property key.
        value - the property value. If null, the property is deleted.
        Throws:
        SQLException - if encounter an sql exception
      • setProperty

        public void setProperty​(String name,
                                String value)
                         throws SQLException
        Sets the property with the specified key and value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted. If the specified value is null, the property is deleted.
        Parameters:
        name - the property key.
        value - the property value. If null, the property is deleted.
        Throws:
        SQLException - if encounter an sql exception
      • setDuplicateFilteringOption

        public void setDuplicateFilteringOption​(String tableName,
                                                boolean value)
                                         throws SQLException
        Sets the Duplicate filtering table property with the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
        Parameters:
        tableName - Name of the structure table.
        value - The duplicate filtering property value.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        JChem 5.4
      • setAbsoluteStereoOption

        public void setAbsoluteStereoOption​(String tableName,
                                            boolean value)
                                     throws SQLException
        Sets the Absolute stereo table property with the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
        Parameters:
        tableName - Name of the structure table.
        value - The absolute stereo property value.
        Throws:
        SQLException - if encounter an sql exception
      • setTautomerDuplicateFilteringOption

        public void setTautomerDuplicateFilteringOption​(String tableName,
                                                        boolean value)
                                                 throws SQLException
        Sets the Tautomer duplicate checking table property with the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
        Parameters:
        tableName - Name of the structure table.
        value - The tautomer duplicate checking property value.
        Throws:
        SQLException - if encounter an sql exception
      • setStandardizerConfigOption

        public void setStandardizerConfigOption​(String tableName,
                                                String value)
                                         throws SQLException
        Sets the standardizer configuration table property to the specified value in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
        Parameters:
        tableName - Name of the structure table.
        value - The standardizer configuration string.
        Throws:
        SQLException - if encounter an sql exception
      • setTableProperty

        public void setTableProperty​(String tableName,
                                     String propName,
                                     String propValue)
                              throws SQLException
        Sets the given table property in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
        Parameters:
        tableName - Name of the structure table.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
        propValue - the value of the property
        Throws:
        SQLException - if encounter an sql exception
      • getTableProperty

        public String getTableProperty​(String tableName,
                                       String propName)
                                throws SQLException
        Gets a table property from the JChemProperties table.
        Parameters:
        tableName - Name of the structure table.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
        Returns:
        The value of table property if it is stored in the JChemProperties table, null otherwise.
        Throws:
        SQLException - if encounter an sql exception
      • getTableIntProperty

        public int getTableIntProperty​(String tableName,
                                       String propName)
                                throws IllegalArgumentException,
                                       NumberFormatException,
                                       SQLException
        Gets an integer table property from the JChemProperties table.
        Parameters:
        tableName - Name of the structure table.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
        Returns:
        The value of table property if it is stored in the JChemProperties table and can be parsed to int.
        Throws:
        IllegalArgumentException - if the given property is not found.
        NumberFormatException - if the given property cannot be parsed to int.
        SQLException - if encounter an sql exception
      • deleteTableProperty

        public void deleteTableProperty​(String tableName,
                                        String propName)
                                 throws SQLException
        Removes a table property from the JChemProperties table.
        Parameters:
        tableName - Name of the structure table.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
        Throws:
        SQLException - if encounter an sql exception
      • deleteTableProperties

        public void deleteTableProperties​(String tableName)
                                   throws SQLException
        Removes all table properties related to the given structure table from the JChemProperties table.
        Parameters:
        tableName - Name of the structure table.
        Throws:
        SQLException - if encounter an sql exception
      • setMDTableProperty

        public void setMDTableProperty​(String tableName,
                                       String descrName,
                                       String propName,
                                       String propValue)
                                throws SQLException
        Sets the given MD table property in the JChemProperties table. If the property exists with the specified name, then it is updated, otherwise a new row is inserted.
        Parameters:
        tableName - Name of the structure table.
        descrName - Name of the descriptor.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
        propValue - the value of the property
        Throws:
        SQLException - if encounter an sql exception
      • getMDTableProperty

        public String getMDTableProperty​(String tableName,
                                         String descrName,
                                         String propName)
                                  throws SQLException
        Gets MD table property from the JChemProperties table.
        Parameters:
        tableName - Name of the structure table.
        descrName - Name of the descriptor.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constants defined in PropertyConstants.Table.
        Returns:
        The value of table property if it is stored in the JChemProperties table, null otherwise.
        Throws:
        SQLException - if encounter an sql exception
      • deleteMDTableProperty

        public void deleteMDTableProperty​(String tableName,
                                          String descrName,
                                          String propName)
                                   throws SQLException
        Removes MD table property from the JChemProperties table.
        Parameters:
        tableName - Name of the structure table.
        descrName - Name of the descriptor.
        propName - Name of the property. It is case sensitive, e.g. "JChemVersion" is not the same as "jchemVersion". Use the constans defined in PropertyConstants.Table.
        Throws:
        SQLException - if encounter an sql exception
      • incrementProperty

        public long incrementProperty​(String name)
                               throws SQLException
        Increments the value of property with the specified key by one. Value has to be in integer format. If the property doesn't exist with the specified name, then a row with the value 1 is inserted.
        Parameters:
        name - the property key.
        Returns:
        the new value of the property
        Throws:
        SQLException - if encounter an sql exception
      • deleteProperty

        public void deleteProperty​(String name)
                            throws SQLException
        Removes the row with the specified key from the JChemProperties table, if it exists.
        Parameters:
        name - the property key.
        Throws:
        SQLException - if encounter an sql exception
      • propertyTableExists

        public static boolean propertyTableExists​(ConnectionHandler conh)
        Checks if JChem property table exists.
        Parameters:
        conh - must contain at minimum a live connection and a property table name
        Returns:
        true if the table exists
      • createPropertyTable

        public static void createPropertyTable​(ConnectionHandler conh)
                                        throws SQLException
        Creates a new property table for storing JChem's settings. It is recommended to test first if the table exists, by calling propertyTableExists
        Parameters:
        conh - it should contain at minimum a live connection and a property table name If your database server type is MySql, recommend to use the other createPropertyTable method
        Throws:
        SQLException - if encounter an sql exception
        See Also:
        createPropertyTable(ConnectionHandler, int)
      • getStructureTableNames

        public Vector<String> getStructureTableNames()
                                              throws SQLException
        Returns the names of structure tables registered in the JChemProperties table.
        Returns:
        a vector of all structure table names
        Throws:
        SQLException - if encounter an sql exception
      • getMolecularDescriptors

        public String[] getMolecularDescriptors​(String tableName)
                                         throws SQLException
        Retrieves the names of MolecularDescriptors assigned to the structure table and stored in the JChem database.
        Parameters:
        tableName - the name of the structure table
        Returns:
        the descriptor names
        Throws:
        SQLException - if encounter an sql exception
      • isMolecularDescriptorDefined

        public boolean isMolecularDescriptorDefined()
                                             throws SQLException
        Retrieve whether at least one MolecularDescriptor is defined for any table or not.
        Returns:
        true if at least one descriptor table exists
        Throws:
        SQLException - if encounter an sql exception
      • getMDConfigs

        public String[] getMDConfigs​(String tableName,
                                     String descriptorName)
                              throws SQLException
        Retrieves the names of stored configurations associated with a certain Molecular Descriptor.
        Doesn't support JChem Cartridge index tables.
        Parameters:
        tableName - the name of the structure table
        descriptorName - the name of the molecular descriptor
        Returns:
        the names of the configurations
        Throws:
        SQLException - if encounter an sql exception
      • isUsePreparedStatement

        public boolean isUsePreparedStatement()
      • setUsePreparedStatement

        public void setUsePreparedStatement​(boolean usePreparedStatement)
        Specifies if PreparedStatement should be used for property lookup. Recommended if properties are read from the table very frequently. NOTE: If set to true, close() should be called after usage.
        Parameters:
        usePreparedStatement - set to true to use preapared statements for reading data. Default is false
      • getChemTermColumns

        public String[] getChemTermColumns​(String tableName)
                                    throws SQLException
        Returns the name of columns with values automatically calculated based on Chemical Terms expressions.
        Parameters:
        tableName - the table, the Chemical Terms-based columns of which should be returned.
        Returns:
        the name of columns with values automatically calculated based on Chemical Terms expressions.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        3.2
      • isChemTermColumnDefined

        public boolean isChemTermColumnDefined()
                                        throws SQLException
        Retrieve whether at least one Chemical Term column is defined for any table or not.
        Returns:
        boolean
        Throws:
        SQLException - if encounter an sql exception
      • setChemTermForColumn

        public void setChemTermForColumn​(String tableName,
                                         String columnName,
                                         String expression)
                                  throws SQLException
        Sets the Chemical Terms expression that should be used to compute the value for the given column.
        Parameters:
        tableName - name of the table containing the column
        columnName - name fo the column with pre-computed Chemical Terms values.
        expression - the Chemical Terms expression that should be used to compute the value for the given column.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        3.2
      • getChemTermForColumn

        public String getChemTermForColumn​(String tableName,
                                           String columnName)
                                    throws SQLException
        Gets the Chemical Terms expression that should be used to compute the value for the given column.
        Parameters:
        tableName - name of the table containing the column
        columnName - name of the column with pre-computed Chemical Terms values.
        Returns:
        the Chemical Terms expression that should be used to compute the value for the given column.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        3.2
      • deleteChemTermForColumn

        public void deleteChemTermForColumn​(String tableName,
                                            String columnName)
                                     throws SQLException
        Deletes the property defining the Chemical Terms expression that should be used to compute the value for the given column.
        Parameters:
        tableName - name of the table containing the column
        columnName - name fo the column with pre-computed Chemical Terms values.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        3.2
      • setCacheRegistrationTableName

        public String setCacheRegistrationTableName()
                                             throws SQLException
        Set the name of the cache registration table for the current property table.
        Returns:
        the newly generated table name.
        Throws:
        SQLException - if encounter an sql exception
      • getCacheRegistrationTableName

        public String getCacheRegistrationTableName()
                                             throws SQLException
        Get the cache registration table name of the currently used property table.
        Returns:
        the cache registration table name.
        Throws:
        SQLException - if encounter an sql exception
      • isTautomerDuplicateFilteringEnabled

        public boolean isTautomerDuplicateFilteringEnabled​(String tableName)
                                                    throws SQLException
        Returns whether tautomers are considered during duplicate filtering for this table.
        Parameters:
        tableName - the name of the JChem structure table
        Returns:
        true if tautomer duplicate filtering is enabled for the table
        Throws:
        SQLException - if encounter an sql exception
        Since:
        JChem 5.0
      • getTautomerEqualityMode

        public chemaxon.sss.search.options.TautomerTransformationMode getTautomerEqualityMode​(String tableName)
                                                                                       throws SQLException
        Throws:
        SQLException
      • isDatabaseReadonly

        public boolean isDatabaseReadonly()
                                   throws SQLException
        Returns whether database of the current JChem property table is readonly.
        Returns:
        true if the database is readonly
        Throws:
        SQLException - if encounter an sql exception
        Since:
        JChem 5.3.2
      • getFingerprintParams

        public String[] getFingerprintParams​(String tableName)
                                      throws SQLException
        Return the fingerprint parameters of a table.
        Parameters:
        tableName - the name of the table
        Returns:
        array that contains 3 elements, the first is the number of bits, the second is the number of ones, the third is the number of edges.
        Throws:
        SQLException - if encounter an sql exception
      • getTableProperties

        public Map<String,​String> getTableProperties​(String tableName)
                                                    throws SQLException
        Return all properties for a table.
        Parameters:
        tableName - Name of the structure table
        Returns:
        the property names and values
        Throws:
        SQLException - if encounter an sql exception
      • isDuplicateFilteringOption

        public boolean isDuplicateFilteringOption​(String tableName)
                                           throws SQLException
        Returns the state of the Duplicate Filtering table option.
        Parameters:
        tableName - Name of the structure table
        Returns:
        the state of the Duplicate Filtering option from the JChem Property Table.
        Throws:
        SQLException - if encounter an sql exception
        Since:
        Jchem 5.4
      • getAllProperties

        public StringBuilder getAllProperties()
                                       throws SQLException
        Returns all properties in the JChem property table.
        Returns:
        all property names and values in a formatted StringBuffer
        Throws:
        SQLException - if encounter an sql exception
      • getCacheRegistrationTableName

        public static String getCacheRegistrationTableName​(ConnectionHandler conh)
                                                    throws SQLException
        Get the table name containing the registration information
        Parameters:
        conh - ConnectionHandler to use
        Returns:
        registration table name
        Throws:
        SQLException - if encounter an sql exception
      • getDbmsType

        public int getDbmsType()
      • getCacheUpdaterType

        public chemaxon.jchem.base.storage.cache.CacheUpdaterType getCacheUpdaterType​(String tableName)
                                                                               throws SQLException
        Throws:
        SQLException
      • setCacheUpdaterType

        public void setCacheUpdaterType​(String tableName,
                                        chemaxon.jchem.base.storage.cache.CacheUpdaterType cacheUpdaterType)
                                 throws SQLException
        Throws:
        SQLException