psdi.configure

Class UpgTemplate

  • java.lang.Object
    • psdi.configure.UpgTemplate
  • All Implemented Interfaces:
    UpgConstants


    public abstract class UpgTemplate
    extends java.lang.Object
    implements UpgConstants
    Template for specialized classes called during the upgrade process from ConfigDB and RestoreFromBackup.

    Extensions of this class for ConfigDB should be named "UpgCdb" + ConfigDB methodName + ConfigDB methodPlace (or null) + table name (uppercase) (or null).

    Extensions of this class for RestoreFromBackup should be named "UpgRes" + RestoreFromBackup methodName + RestoreFromBackup methodPlace (or null) + table name (uppercase) (or null).

    For example, if this will be called from ConfigDB, method rebuildTable, place 01, table Item, then the name of this class would be: UpgCdbRebuildTable01ITEM.

    The subdirectory containing these extensions is determined as follows. Find the name of the maxvar MAXUPG from the database that you are converting from. Use the first part of the varvalue up to but not including any space or hyphen character. For example, if the varvalue equals V411-06 3/23/2001, then the name of the subdirectory would be psdi.configure.V411.

    See Also:
    psdi.upgrade.Upgrade#upgradeCallout, ConfigDB.upgradeCallout(java.lang.String, java.lang.String, java.lang.String), RestoreFromBackup.upgradeCallout(java.lang.String, java.lang.String, java.lang.String)
    • Field Detail

      • sYes

        public java.lang.String sYes
        The value indicating Yes for YORN attributes.
      • sNo

        public java.lang.String sNo
        The value indicating No for YORN attributes.
      • shell

        protected CommonShell shell
        Link to the common shell
    • Constructor Detail

      • UpgTemplate

        public UpgTemplate(CommonShell shell)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • process

        public abstract boolean process()
                                 throws java.lang.Exception
        This method must be overridden by the instance of UpgTemplate to perform whatever special processing is required for the upgrade.
        Throws:
        java.lang.Exception
      • doSql

        public void doSql(java.util.AbstractList list)
                   throws java.lang.Exception
        Loops through an array and calls doSql for each element.
        Parameters:
        list - Any instance or extension of AbstractList, including ArrayList, etc.
        Throws:
        java.lang.Exception
        See Also:
        UpgTemplate.doSql(String)
      • doSql

        public void doSql(java.lang.String sql)
                   throws java.lang.Exception
        Looks at params to determine whether the execute only, log only, or both execute and log.
        Parameters:
        sql - The Sql statement
        Throws:
        java.lang.Exception
      • buildRenameColumnStatement

        public java.util.ArrayList buildRenameColumnStatement(java.lang.String tableName,
                                                              java.lang.String oldColumnName,
                                                              java.lang.String newColumnName)
        Generate a series of sql statements to rename a column within a table. The sql statements:
        1. Alter the native column name.
        2. Delete the old column name from MAXATTRIBUTECFG.
        3. Modify MAXATTRIBUTECFG.CHANGED for new column, from 'I' to 'Y'.
        4. Change MAXATTRIBUTE.ATTRIBUTENAME to new column name.
        Parameters:
        tableName - Name of the table
        oldColumnName - Original/Current name of the column
        newColumnName - New name of the column
        Returns:
        ArrayList List of sql commands to rename the column
      • showMXException

        public void showMXException(MXApplicationException e,
                                    boolean infoOnly,
                                    boolean hideErrorKey)
        Display a message to the console and to the logfile, including errorGroup and errorKey.
        Parameters:
        e - The MXApplicationException; must have error group "configdb".
        infoOnly - True if this is an Info message, False is this is an Error (or Warning) message.
        hideErrorKey - True to hide the errorGroup and errorKey. This would be True for messages such as the header of the Unlcvt output.
        See Also:
        UpgTemplate.getDisplayMessage(java.lang.String, java.lang.Object[])
      • getDisplayMessage

        public java.lang.String getDisplayMessage(java.lang.String errorkey,
                                                  java.lang.Object[] params)
        Error group is assumed to be "configdb".
        Parameters:
        errorkey -
        params -
        Returns:
        String of message with param substitutions (if any).
      • getDisplayMessage

        public java.lang.String getDisplayMessage(java.lang.String errorgroup,
                                                  java.lang.String errorkey,
                                                  java.lang.Object[] params)
        Get Message from XLIFF Hashmap, using group and key.
        Parameters:
        errorgroup -
        errorkey -
        params -
        Returns:
        String of message with param substitutions (if any).
      • getDisplayMessage

        public java.lang.String getDisplayMessage(java.lang.String errorkey)
        Call getDisplayMessage with null second param. Error group is assumed to be "configdb".
        Parameters:
        errorkey -
        Returns:
        String of message.
      • showMXException

        public void showMXException(MXApplicationException e)
        Display a message to the console and to the logfile, including errorGroup and errorKey. Call {#link #showMXException(MXApplicationException, boolean) showMXException} with second parameter False.
        Parameters:
        e - The MXApplicationException; must have error group "configdb".
      • showMsg

        public final void showMsg(java.lang.String str)
        Display a one-line "info" message to the console and to the logfile.
        Parameters:
        str - The one-line message to be displayed.
      • getDbIn

        public final int getDbIn()
        Returns:
        Returns the dbIn.
      • getDbConnection

        public final java.sql.Connection getDbConnection()
        Returns:
        Returns the dbConnection.
      • getLogStream

        public final java.io.PrintStream getLogStream()
        Returns:
        Returns the logStream.
      • getUtil

        public final Util getUtil()
        Returns:
        Returns the util.
      • getSchemaOwner

        public final java.lang.String getSchemaOwner()
      • isLoggingSql

        public final boolean isLoggingSql()
        Returns:
        Returns true when the application is logging sql.
      • isExecutingSql

        public final boolean isExecutingSql()
        Returns:
        Returns true is the application is executing sql.
      • logError

        protected final void logError(java.lang.String msg)
        Special use method for Validate callouts only.
        Parameters:
        msg -
      • createTemporaryIndex

        protected java.lang.String createTemporaryIndex(java.lang.String tableName,
                                                        java.lang.String[] columns,
                                                        boolean unique)
                                                 throws java.lang.Exception
        Create a temporary index on the specifed tables and columns. Called to create temporary indexes to improve performance. Generates a name for the index and verifies the name is unique.
        Parameters:
        tableName - Name of table to be indexed.
        columns - List of columns to be indexed.
        Returns:
        Name of the index created; null if no index created.
        Throws:
        java.lang.Exception
      • dropTemporaryIndex

        protected void dropTemporaryIndex(java.lang.String ixname,
                                          java.lang.String tbname)
                                   throws java.lang.Exception
        Drop an index - the syntax differs between the servers types.
        Parameters:
        ixname - The name of the index to drop.
        tbname - The name of the table the index is on.
        Throws:
        java.lang.Exception
      • updateStatistics

        public void updateStatistics(java.util.ArrayList tables,
                                     java.util.TreeMap indexes)
                              throws MXException,
                                     java.rmi.RemoteException
        Executes "analyze table/compute statistics" (for Oracle) or "update statistics" (for SqlServer) for the specified tables/indexes; For use by app callouts

        Parameters:
        tables - TreeMap of object metata, for Oracle. (Not used for SqlServer.)
        indexes - TreeMap of index metadata for SqlServer. (Not used for Oracle.)
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Util.nativeIndexExists(java.lang.String, java.lang.String)
      • doSqlProcedure

        public void doSqlProcedure(java.lang.String storedProcedure,
                                   java.util.LinkedHashMap parameters)
                            throws java.lang.Exception
        Execute a stored procedure from the database
        Parameters:
        storedProcedure - Sql statement in the format 'CALL proc_name(?,?,?)'
        parameters - Input parameters of the procedure, LinkedHashMap with entries (Object, Integer) where Object is the parameter and Integer is the data type Types
        Throws:
        java.lang.Exception