Class MetadataManager


  • public final class MetadataManager
    extends java.lang.Object
    Class to handle persistence of an intermine objectstore's metadata to the objectstore's database
    Author:
    Mark Woodbridge
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AUTOCOMPLETE_INDEX
      The name of the key to use to store the autocomplete RAMIndexes.
      static java.lang.String BG_PROPERTIES
      The name of the key used to store the bluegenes properties.
      static java.lang.String CLASS_KEYS
      The name of the key to use to store the class_keys.properties file.
      static java.lang.String KEY_DEFINITIONS
      Name of the key under which to store the serialized version of the key definitions
      static java.lang.String METADATA_TABLE
      Name of the metadata table (created by TorqueModelOutput)
      static java.lang.String MISSING_TABLES
      The name of the key used to store the missing tables string.
      static java.lang.String MODEL
      Name of the key under which to store the serialized version of the model
      static java.lang.String MODMINE_METADATA_CACHE
      The name of the key used to store the modMine MetaData cache
      static java.lang.String NO_NOTXML
      The name of the key used to store the noNotXml string.
      static java.lang.String OS_FORMAT_VERSION
      The name of the key used to store objectstore format version number.
      static java.lang.String OS_SUMMARY
      The name of the key to use to store the objectstoresummary.properties file.
      static java.lang.String PROFILE_FORMAT_VERSION
      The name of the key used to store profile format version.
      static java.lang.String RANGE_DEFINITIONS
      Description of range type columns defined in the database.
      static java.lang.String SEARCH_INDEX
      The name of the key to use to store the search index.
      static java.lang.String SEARCH_INDEX_DIRECTORY
      The name of the key to use to store the search Directory.
      static java.lang.String SERIAL_NUMBER
      The name of the key used to store the serial number identifying the production db
      static java.lang.String TRUNCATED_CLASSES
      The name of the key used to store the truncated classes string.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean deleteLargeBinary​(Database database, java.lang.String key)
      Delete a large object from the database based on a given metadata key.
      static java.lang.String getFilename​(java.lang.String key, java.lang.String modelName)
      Given a key and model name, return filename for reading/writing.
      static java.util.Properties loadClassKeyDefinitions()
      Load the class key / key field definitions.
      static java.util.Properties loadKeyDefinitions​(java.lang.String modelName)
      Load the key definitions file for the named model from the classpath
      static MetadataManager.LargeObjectInputStream readLargeBinary​(Database database, java.lang.String key)
      Returns an InputStream object with which to read a large binary value from the database.
      static java.lang.String retrieve​(Database database, java.lang.String key)
      Retrieve the value for a given key from the metadata table of the database
      static java.io.InputStream retrieveBLOBInputStream​(Database database, java.lang.String key)
      Retrieve the BLOB value for a given key from the metadata table of the database
      static void saveClassKeys​(java.lang.String properties, java.io.File destDir)
      Save the class keys, in serialized form, to the specified directory
      static void saveKeyDefinitions​(java.lang.String properties, java.io.File destDir, java.lang.String modelName)
      Save the key definitions, in serialized form, to the specified directory
      static void saveModel​(Model model, java.io.File destDir)
      Save a model, in serialized form, to the specified directory
      static void saveProperties​(java.lang.String properties, java.io.File destDir, java.lang.String fileName)
      Save the objectstore summary, in serialized form, to the specified directory
      static void store​(Database database, java.lang.String key, java.lang.String value)
      Store a (key, value) pair in the metadata table of the database
      static void storeBinary​(Database database, java.lang.String key, byte[] value)
      Store a binary (key, value) pair in the metadata table of the database
      static MetadataManager.LargeObjectOutputStream storeLargeBinary​(Database database, java.lang.String key)
      Returns an OutputStream object with which to write a large binary value to the database.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • METADATA_TABLE

        public static final java.lang.String METADATA_TABLE
        Name of the metadata table (created by TorqueModelOutput)
        See Also:
        Constant Field Values
      • MODEL

        public static final java.lang.String MODEL
        Name of the key under which to store the serialized version of the model
        See Also:
        Constant Field Values
      • KEY_DEFINITIONS

        public static final java.lang.String KEY_DEFINITIONS
        Name of the key under which to store the serialized version of the key definitions
        See Also:
        Constant Field Values
      • CLASS_KEYS

        public static final java.lang.String CLASS_KEYS
        The name of the key to use to store the class_keys.properties file.
        See Also:
        Constant Field Values
      • OS_SUMMARY

        public static final java.lang.String OS_SUMMARY
        The name of the key to use to store the objectstoresummary.properties file.
        See Also:
        Constant Field Values
      • AUTOCOMPLETE_INDEX

        public static final java.lang.String AUTOCOMPLETE_INDEX
        The name of the key to use to store the autocomplete RAMIndexes.
        See Also:
        Constant Field Values
      • SEARCH_INDEX

        public static final java.lang.String SEARCH_INDEX
        The name of the key to use to store the search index.
        See Also:
        Constant Field Values
      • SEARCH_INDEX_DIRECTORY

        public static final java.lang.String SEARCH_INDEX_DIRECTORY
        The name of the key to use to store the search Directory.
        See Also:
        Constant Field Values
      • OS_FORMAT_VERSION

        public static final java.lang.String OS_FORMAT_VERSION
        The name of the key used to store objectstore format version number.
        See Also:
        Constant Field Values
      • PROFILE_FORMAT_VERSION

        public static final java.lang.String PROFILE_FORMAT_VERSION
        The name of the key used to store profile format version.
        See Also:
        Constant Field Values
      • TRUNCATED_CLASSES

        public static final java.lang.String TRUNCATED_CLASSES
        The name of the key used to store the truncated classes string.
        See Also:
        Constant Field Values
      • MISSING_TABLES

        public static final java.lang.String MISSING_TABLES
        The name of the key used to store the missing tables string.
        See Also:
        Constant Field Values
      • NO_NOTXML

        public static final java.lang.String NO_NOTXML
        The name of the key used to store the noNotXml string.
        See Also:
        Constant Field Values
      • MODMINE_METADATA_CACHE

        public static final java.lang.String MODMINE_METADATA_CACHE
        The name of the key used to store the modMine MetaData cache
        See Also:
        Constant Field Values
      • SERIAL_NUMBER

        public static final java.lang.String SERIAL_NUMBER
        The name of the key used to store the serial number identifying the production db
        See Also:
        Constant Field Values
      • RANGE_DEFINITIONS

        public static final java.lang.String RANGE_DEFINITIONS
        Description of range type columns defined in the database.
        See Also:
        Constant Field Values
      • BG_PROPERTIES

        public static final java.lang.String BG_PROPERTIES
        The name of the key used to store the bluegenes properties.
        See Also:
        Constant Field Values
    • Method Detail

      • store

        public static void store​(Database database,
                                 java.lang.String key,
                                 java.lang.String value)
                          throws java.sql.SQLException
        Store a (key, value) pair in the metadata table of the database
        Parameters:
        database - the database
        key - the key
        value - the value
        Throws:
        java.sql.SQLException - if an error occurs
      • storeBinary

        public static void storeBinary​(Database database,
                                       java.lang.String key,
                                       byte[] value)
                                throws java.sql.SQLException
        Store a binary (key, value) pair in the metadata table of the database
        Parameters:
        database - the database
        key - the key
        value - the byte array of the value
        Throws:
        java.sql.SQLException - if an error occurs
      • retrieve

        public static java.lang.String retrieve​(Database database,
                                                java.lang.String key)
                                         throws java.sql.SQLException
        Retrieve the value for a given key from the metadata table of the database
        Parameters:
        database - the database
        key - the key
        Returns:
        the value
        Throws:
        java.sql.SQLException - if an error occurs
      • retrieveBLOBInputStream

        public static java.io.InputStream retrieveBLOBInputStream​(Database database,
                                                                  java.lang.String key)
                                                           throws java.sql.SQLException
        Retrieve the BLOB value for a given key from the metadata table of the database
        Parameters:
        database - the database
        key - the key
        Returns:
        the InputStream of the value
        Throws:
        java.sql.SQLException - if an error occurs
      • storeLargeBinary

        public static MetadataManager.LargeObjectOutputStream storeLargeBinary​(Database database,
                                                                               java.lang.String key)
                                                                        throws java.sql.SQLException
        Returns an OutputStream object with which to write a large binary value to the database. The OutputStream should be closed correctly when the writing is finished in order for the value to be committed to the database and the connection released.
        Parameters:
        database - the database
        key - the key
        Returns:
        an OutputStream to write to
        Throws:
        java.sql.SQLException - if an error occurs
      • deleteLargeBinary

        public static boolean deleteLargeBinary​(Database database,
                                                java.lang.String key)
                                         throws java.sql.SQLException
        Delete a large object from the database based on a given metadata key. If no large object or row in the intermine_metadata table exists nothing will be done.
        Parameters:
        database - the objectstore database
        key - the row in the intermine_metadata table
        Returns:
        true if a blob was found and deleted
        Throws:
        java.sql.SQLException - if an error occurs
      • readLargeBinary

        public static MetadataManager.LargeObjectInputStream readLargeBinary​(Database database,
                                                                             java.lang.String key)
                                                                      throws java.sql.SQLException
        Returns an InputStream object with which to read a large binary value from the database. The InputStream should be closed correctly when the reading is finished in order for the connection to be released.
        Parameters:
        database - the database
        key - the key
        Returns:
        an InputStream to read from
        Throws:
        java.sql.SQLException - if an error occurs
      • saveModel

        public static void saveModel​(Model model,
                                     java.io.File destDir)
                              throws java.io.IOException
        Save a model, in serialized form, to the specified directory
        Parameters:
        model - the model
        destDir - the destination directory
        Throws:
        java.io.IOException - if an error occurs
      • loadKeyDefinitions

        public static java.util.Properties loadKeyDefinitions​(java.lang.String modelName)
        Load the key definitions file for the named model from the classpath
        Parameters:
        modelName - the model name
        Returns:
        the key definitions
      • loadClassKeyDefinitions

        public static java.util.Properties loadClassKeyDefinitions()
        Load the class key / key field definitions.
        Returns:
        the class key definitions
      • saveKeyDefinitions

        public static void saveKeyDefinitions​(java.lang.String properties,
                                              java.io.File destDir,
                                              java.lang.String modelName)
                                       throws java.io.IOException
        Save the key definitions, in serialized form, to the specified directory
        Parameters:
        properties - the key definitions
        destDir - the destination directory
        modelName - the name of the associated model, used the generate the filename
        Throws:
        java.io.IOException - if an error occurs
      • saveClassKeys

        public static void saveClassKeys​(java.lang.String properties,
                                         java.io.File destDir)
                                  throws java.io.IOException
        Save the class keys, in serialized form, to the specified directory
        Parameters:
        properties - the class keys
        destDir - the destination
        Throws:
        java.io.IOException - if an error occurs
      • saveProperties

        public static void saveProperties​(java.lang.String properties,
                                          java.io.File destDir,
                                          java.lang.String fileName)
                                   throws java.io.IOException
        Save the objectstore summary, in serialized form, to the specified directory
        Parameters:
        properties - the summary
        destDir - the destination directory
        fileName - the name destination file
        Throws:
        java.io.IOException - if an error occurs
      • getFilename

        public static java.lang.String getFilename​(java.lang.String key,
                                                   java.lang.String modelName)
        Given a key and model name, return filename for reading/writing.
        Parameters:
        key - key name
        modelName - the name of the model
        Returns:
        name of file